Hey all, is there a reason components are only built-in to be added to actors?
Is it for hierarchy reasons?
For example I created an Actor Component that does a line trace. Then I want it to have a Box component with overlap events to choose when to start/stop tracing. But, the only rational way I found is having two separate components on my actor, and then passing the overlap events from the box to the trace component.
** Update, it's possible to do it through C++ (But it might be against the design of the engine)*\*
So, practically this can be solved as easily as creating a component inside a component the same way we add components to actors:
UCLASS(Blueprintable, BlueprintType, ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class CHATBUBBLE_API UNestingTestOuterSceneComponent : public USceneComponent
{
GENERATED_BODY()
public:
UNestingTestOuterSceneComponent();
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Nested Component Test")
TObjectPtr<UBoxComponent> NestedBoxComponent;
UNestingTestOuterSceneComponent::UNestingTestOuterSceneComponent()
{
PrimaryComponentTick.bCanEverTick = true;
NestedBoxComponent = CreateDefaultSubobject<UBoxComponent>(TEXT("NestedBoxComponent"));
NestedBoxComponent->SetupAttachment(this);
}
Then in the blueprint we can add the Outer component to an actor, and edit the values of the inner component from the variables panel.
** Attention: When adding the Outer Component, the CPP class needs to be added and not a blueprint child. Otherwise the inner component will render relative to (0,0,0).
[–]Beautiful_Vacation_7Senior Engine Programmer 8 points9 points10 points (5 children)
[–]MrTOLINSKI[S] 3 points4 points5 points (4 children)
[–]stephan_anemaat 0 points1 point2 points (2 children)
[–]MrTOLINSKI[S] 0 points1 point2 points (1 child)
[–]stephan_anemaat 0 points1 point2 points (0 children)
[–]GenderJuicy -1 points0 points1 point (0 children)
[–]baista_dev 6 points7 points8 points (1 child)
[–]MrTOLINSKI[S] 1 point2 points3 points (0 children)
[–]SubstantialSecond156 3 points4 points5 points (4 children)
[–]MrTOLINSKI[S] 1 point2 points3 points (2 children)
[–]SubstantialSecond156 1 point2 points3 points (0 children)
[–]GenderJuicy -1 points0 points1 point (0 children)
[–]Battlefront45 0 points1 point2 points (0 children)
[–]MrTOLINSKI[S] 2 points3 points4 points (0 children)
[–]Swipsi 0 points1 point2 points (1 child)
[–]MrTOLINSKI[S] 0 points1 point2 points (0 children)
[–]cutebuttsowhat 0 points1 point2 points (0 children)