Attaching static meshes to scene component causes them to disappear?

Hello! I’m somewhat new to UE4’s c++ usage and having a little bit of difficulty. I am attempting to make an actor that will appear and disappear based on a timer. I was able to get my original draft of the actor working just fine, when there was only one component involved. However, it was difficult to tell where objects would appear when the timer expired, so I decided to add a ‘hint’ mesh that I would texture such that it would appear as a transparent guide of sorts.

However, when attaching my ‘hint’ mesh to my root mesh, I have run into a problem: when dragging my blueprint that derives from this class into the world, the attached hint mesh appears at the level’s origin (0, 0, 0), while the root mesh appears wherever the blueprint was placed. From that point, it seems to move in sync with the root mesh, always maintaining the same offset.

After some google searching, I managed to find a similar question that suggested it might be a bug caused by attaching static meshes to static meshes. As a workaround, I decided to implement a scene component as the root and attach both to that. Now, however, the meshes are not even being rendered(!) when placed in the world. The actor is treated as a point in space with no physical representation. What am I doing wrong, here? Am I missing something really obvious?

.h

// The static mesh to use for the switchable object.
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Mesh)
UStaticMesh* MeshAsset;

// The material to use for the switchable object. The material should
// include a parameter called 'ShowAmount'.
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Mesh)
	UMaterial* MaterialAsset;

// The material (ideally translucent) to use for the hint that this
// object will appear.
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Mesh)
	UMaterial* HintMaterialAsset;

// The object's scene component. The root component.
USceneComponent* SceneComponent;

// The object's mesh. Used for collision.
UStaticMeshComponent* MeshComponent;

//A hint mesh to show where the object appears
UStaticMeshComponent* HintMeshComponent; 

.cpp

// Sets default values
AGateSwitchableActor::AGateSwitchableActor()
{
 	// 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;

	SceneComponent = CreateDefaultSubobject< USceneComponent >(TEXT("SceneLocation"));
	SceneComponent->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
	RootComponent = SceneComponent;

	MeshComponent = CreateDefaultSubobject< UStaticMeshComponent >(TEXT("StaticMeshComponent"));
	MeshComponent->AttachTo(RootComponent);
	MeshComponent->SetRelativeScale3D(FVector(1.0f, 1.0f, 1.0f));
	MeshComponent->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));

	HintMeshComponent = CreateDefaultSubobject< UStaticMeshComponent >(TEXT("HintMesh"));
	HintMeshComponent->AttachTo(RootComponent);
	HintMeshComponent->SetCollisionProfileName(FName("OverlapOnlyPawn"));
	HintMeshComponent->SetRelativeScale3D(FVector(1.1f, 1.1f, 1.1f)); //slightly bigger
	HintMeshComponent->SetWorldLocation(MeshComponent->GetComponentLocation());
	
	ActiveDuration = 5.f;
	AnimationSpeed = 2.f;
	bIsSwitchedOn = false;
	bPlayAnimation = false;
	ShowAmount = 1.f;
}

void AGateSwitchableActor::PostInitializeComponents()
{
	Super::PostInitializeComponents();

    //Set our component's meshes based on what has been selected in the derived blueprint.
    //Cannot be done in constructor because it needs to talk to blueprint
	if (MeshAsset)
	{
		MeshComponent->SetStaticMesh(MeshAsset);
		HintMeshComponent->SetStaticMesh(MeshAsset);
	}

	if (MaterialAsset)
	{
		MeshComponent->SetMaterial(0, MaterialAsset);
	}
	if (HintMaterialAsset)
	{
		HintMeshComponent->SetMaterial(0, HintMaterialAsset);
	}
}

Hello OhNoLab,

PostInitializeComponents is used for initializing for gameplay purposes, such as BeginPlay. For what you’re looking to do, you’d most likely be looking to PostInitProperties or OnConstruction. I tested both of these using your code that you provided and it seems to work as you intend it to.