Dear experts,
I have a UBoxComponent on a class called Interactable:
//box component for line traces
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UBoxComponent* LineTraceBox;
and in the .cpp I have
// Sets default values
AInteractable::AInteractable()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
//PrimaryActorTick.bCanEverTick = true;
Name = "Interactable";
Action = "interact";
FVector TriggerBoxSize = FVector(30.0f,30.0f,30.0f);
//we add this box to our interactable objects.
//sometimes the mesh is really small (cups for example) and hard to hit: the box is bigger and easier to hit
LineTraceBox = CreateDefaultSubobject<UBoxComponent>(TEXT("LineTraceBox"));
LineTraceBox->SetBoxExtent(TriggerBoxSize);
LineTraceBox->SetupAttachment(RootComponent);
LineTraceBox->SetCollisionEnabled(ECollisionEnabled::QueryOnly); //we only need it for the line trace
LineTraceBox->SetCollisionResponseToAllChannels(ECR_Block);
}
Now I have another class inheriting from this base class like this:
class MYTEST AManPickup : public AInteractable
And now I have a blueprint based on the MYTEST C++ class and I can see my Box component and I set it so it shows when I play:
But when I actually play I can’t see the box:
What am I missing here? I feel like something with my inheritance is not okay. Is my UPROPERTY in the base class okay? UPROPERTY(EditAnywhere, BlueprintReadWrite)
Thank you, Peter
EDIT: So what I just did, I went into the BP class and manually added another UBoxComponent, and that works, look at the shots:
So why does it not work when adding the UBoxComponent to the Parent C++ ?
I don’t get it