I create a child actor component and spawn an actor.
Everything seems perfect when I run in Editor mode. However, when I run in Standalone mode, the child actor is not hidden.
Below is part of my code:
.h
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Drone")
UChildActorComponent* DirectionChildActorComponent;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Drone")
ADirectionActor* DirectionActor;
.cpp
ADroneBase::ADroneBase()
{
// 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;
// Some other unrelated code here
DirectionChildActorComponent = CreateDefaultSubobject<UChildActorComponent>(TEXT("DirectionActor"));
DirectionChildActorComponent->SetupAttachment(RootComponent);
DirectionChildActorComponent->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
DirectionChildActorComponent->SetChildActorClass(ADirectionActor::StaticClass());
DirectionChildActorComponent->CreateChildActor();
}
void ADroneBase::BeginPlay()
{
Super::BeginPlay();
UDroneFunctionLibrary::ExecuteMiniSv();
DirectionChildActorComponent->CreateChildActor();
DirectionActor = (ADirectionActor*) DirectionChildActorComponent->GetChildActor();
DirectionActor->SceneComponent->SetVisibility(false);
DirectionActor->SetActorHiddenInGame(true);
//Just for test, and result in "DirectionActor: DirectionActor_DirectionActor_CAT_0"
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, FString::Printf(TEXT("ADroneBase::BeginPlay(), DirectionActor: %s"), *DirectionActor->GetName()));
}
What am I doing wrong in my code?
Or is it a bug for UE4?
Thank you