[C++] Possible Bug? Inherited UStaticMeshComponent looses Mesh on Blueprint Compile when attached through different class then the Actor itself

Hey everybody,

I have a problem with a disappearing mesh:

I created a simple Actor:

MyActor.h

UCLASS()
class VRBASEFRAMEWORK_API AMyActor : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	AMyActor();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	UStaticMeshComponent* ActorMesh;		

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	class UMySceneComponent* ChildScene;
};

MyActor.cpp

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

	ActorMesh= CreateDefaultSubobject<UStaticMeshComponent>(TEXT("ActorMesh"));
	RootComponent = ActorMesh;

	ChildScene = CreateDefaultSubobject<UMySceneComponent>(TEXT("ChildScene"));
	ChildScene->SetupAttachment(ActorMesh);
}

// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
	Super::BeginPlay();
}

// Called every frame
void AMyActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
}

In the constructor i attached a custom scene component which also contains a mesh:

MySceneComponent.h

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class VRBASEFRAMEWORK_API UMySceneComponent : public USceneComponent
{
	GENERATED_BODY()

public:	
	// Sets default values for this component's properties
	UMySceneComponent();

protected:
	// Called when the game starts
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
	
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	UStaticMeshComponent* ChildMesh;			
};

MySceneComponent.cpp

// Sets default values for this component's properties
UMySceneComponent::UMySceneComponent()
{
	// Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
	// off to improve performance if you don't need them.
	PrimaryComponentTick.bCanEverTick = true;

	ChildMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Child));
	ChildMesh->SetupAttachment(this);
}


// Called when the game starts
void UMySceneComponent::BeginPlay()
{
	Super::BeginPlay();
}


// Called every frame
void UMySceneComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
}

Then i created a Blueprint which is based on the MyActor class.
In the Blueprint i set the StaticMesh for both the ActorMesh and ChildMesh.

When i compile the Blueprint now the ChildMesh disappears and i don’t know why that is.

Things i’ve noticed is that when I click on ChildMesh (Inherited) in the Components Panel the Details Panel is totally empty. When i click on ActorMesh (Inherited) I can see the Static Mesh Components variables.
Also the StaticMesh is still set in the Details Panel, but it doesn’t show up in the viewport.
Dragging the Actor into a map doesn’t work as well.
Another thing is that i can drag the ActorMesh into the EventGraph and get a Get or Set Node.
If i drag the ChildMesh into the Event Graph it gives the following error:
Cannot find correspondig variable (make sure component has been assigned to one).

I really hope that anyone can help me.

Cheers,
Adrian

Hey ZABBA-

Thank you for submitting a bug report. I have reproduced this issue and logged a report for it here Unreal Engine Issues and Bug Tracker (UE-43439) . You can track the report’s status as the issue is reviewed by our development staff. Please be aware that this issue may not be prioritized or fixed soon.

Cheers

Hey ,

thanks for your fast reply.
I got the same error message again.
This time I cannot access the Component (this time a SkeletalMesh) at all.
When i click on a SkeletalMeshComponent added via the blueprint editor, then i can change the mesh etc.
When the component is added through a member of a C++ subclass (like ChildMesh in MySceneComponent in the example above) it has the same bugs like in the example above.

It seems like the components that are not in the same class as MyActor.h are not initialized correctly.
If i add a component through blueprint as a child to a MotionController component (from c++) it does not follow the Controller, although the position is tracked correctly, as i visualized with the help of a DrawDebugSphere() command.
Also the Details Panel is again empty.

This time i have two ChildClasses of the same type:
LeftHand and RightHand are both of a custom class VRHand.
They both contain a MotionController Component with a SkeletalMesh attached to it.
If I create a Blueprint as a child of my pawn class then besides the bugs above all seems correct in the hierarchy. If i restart the editor something wierd happens as the Components inside the RightHand switch over to the LeftHand.
See the picture for clarification:

139602-componentwronghierarchy.png

I guess all I’m trying to say is that there seems to be more wrong with the C++ class handling in the blueprints than a disappearing mesh.
The whole “custom class as member in another class” seems a little broken.

Thank you very much and best regards,
ZABBA