The question is waiting approval by a moderator.

I posted a question and it has a message at the bottom saying “The question is waiting approval by a moderator.”

Is this something new? Do you know how long it roughly takes for this process to finish. I’m so stuck in my code it hurts hahaha :slight_smile:

Thanks in advance!

If you are so stuck, why not also posting it here?

I have the following actor:


 UCLASS()
class X_API AMoveableRigidBodyActor : public AActor
{
   GENERATED_BODY()

public:

   // Sets default values for this actor's properties
   AMoveableRigidBodyActor();

public:

UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Custom")
   USceneComponent* SceneComponent;

UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Custom")
    UMoveableRigidBodyComponent* MoveableRigidBodyComponent;

};
  

This Actor makes a reference to a UMoveableRigidBodyComponent and a USceneComponent which I run CreateDefaultSubobject on and attach in the following fashion in the constructor:


 AMoveableRigidBodyActor::AMoveableRigidBodyActor()
{

   SceneComponent = CreateDefaultSubobject<USceneComponent>(FName("AMoveableRigidBodyActor_SceneComponent"));
   SetRootComponent(SceneComponent);

   MoveableRigidBodyComponent = CreateDefaultSubobject<UMoveableRigidBodyComponent>(FName("AMoveableRigidBodyActor_MoveableRigidBodyComponent"));
   MoveableRigidBodyComponent->SetupAttachment(SceneComponent);

}
  

So far, so good.

Now inside my UMoveableRigidBodyComponent I instantiate a few components that are relevant to that component. I expect these components to be visible and manageable from within my blueprint:


 UCLASS()
class X_API UMoveableRigidBodyComponent : public USceneComponent
{
   GENERATED_BODY()

public:

   // Sets default values for this component's properties
   UMoveableRigidBodyComponent();

override;

UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Custom")
   USceneComponent* SceneComponent;

UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Custom")
   UStaticMeshComponent* StaticMeshComponent;

};
  

Here I use CreateDefaultSuboject to attach everything to this component:


 UMoveableRigidBodyComponent::UMoveableRigidBodyComponent()
{
   SceneComponent = CreateDefaultSubobject<USceneComponent>(FName("UMoveableRigidBodyComponent_SceneComponent"));
   SceneComponent->SetupAttachment(this);

   StaticMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(FName("UMoveableRigidBodyComponent_StaticMeshComponent"));
   StaticMeshComponent->SetupAttachment(SceneComponent);
}
  

So, all of this feels pretty normal so far. So I go into my editor, create a blueprint that’s based off of the AMoveableRigidBodyActor and I assign a static mesh to my component:

A.jpg

Still good. But then I hit the compile button:

B.jpg

The selected static mesh has now vanished from the editor but still seems to be filling the value correctly.

Furthermore, if I put this into the game world you can see that the static mesh sure enough isn’t there in the instance:

C.jpg

What am I misunderstanding here?

Several years ago I experimented with subcomponents the result was unreliable at best.

Nevertheless what you described also happened to me. If I remember correctly one of the solutions was not creating and attaching the component (with all the subcomponents) via C++ but manually by BP:

](filedata/fetch?id=1840987&d=1607502931)

It wasn’t a good solution, but I didn’t have time to waste.

Maybe I missed something but I moved on and discarted that type of design, since it always felt weird to me.

I recommend you put this issue in the C++ section. Perhaps someone knows how to do it properly.

Indeed I am following this one.

Thanks guys. I’m not sure how to change the section here but as I see my post was now approved in answerhub, I’ll hope for an answer there.
I would love to say "in the meantime I’ll manually add my c++ components in the blueprint, but I’m at an architectural point where I’d best understand this limitation if it is one. Thank you so much.

I have raised the question here in the C++ section: CreateDefaultSubobject inside child component attached to an actor loses values in blueprint editor - C++ Gameplay Programming - Unreal Engine Forums

Took me a while to find out how to do this. Thanks once again for your direction.