ChildActorComponent not showing its variable in BP

Hi, I’ve created a child actor component with actor class “Orb”. However I cannot see the Orb’s skeletal mesh component property inside the editor as well as the other variable I’ve declared in Orb.h. Or am I doing anything wrong here?

Character.h

  //Orb Component
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Orb)
        	class UChildActorComponent* RedOrb;

Character.cpp

RedOrb = ObjectInitializer.CreateDefaultSubobject<UChildActorComponent>(this, TEXT("RedOrb"));
    	RedOrb->RelativeLocation = FVector(0, 0, 0);
    	RedOrb->ChildActorClass = AOrb::StaticClass();

Orb.h

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = SkeletalMesh)
        	class USkeletalMeshComponent* OrbSkeletalMesh;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = State)
		bool bIsBlockEnabled;

Orb.cpp

AOrb::AOrb(const FObjectInitializer& ObjectInitializer)
{

	OrbSkeletalMesh = ObjectInitializer.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("OrbSkeletalMesh"));
}

In Editor as you can see there’s no skeletal mesh and bool bIsBlockEnabled to edit or view.

That’s because on the details panel which you posted the image of, you are looking at the properties of the UChildActorComponent, not of your AOrb class. Your AOrb is an actor, not a component, so its properties will not show up embedded in the parent blueprint.

You need to either:

  1. Make your orb class derive from UActorComponent instead, and create a component of that type within your parent class, in place of the AChildActorComponent; or
  2. If it is correct and you want it to be a separate actor rather than a component, you have to create a blueprint derived from AOrb. You can then modify the properties in that blueprint, and select your blueprint class in the ‘Child Actor Class’ property.

Well the 2nd option is what I needed, but instead of blueprint, how can I achieve the same result using c++? In other word, how can I create and initialize AOrb object so that later on I can access in my character.cpp like RedOrb->somefunction()

Don’t quite follow what you mean by doing the same thing in c++, but to access the actor I guess you just need to do:

Cast< AOrb >(RedOrb->ChildActor)->somefunction();

Note you can only do this once the component has been registered, otherwise the child actor will be null.

It work now but the skeletalmeshcomponent in AOrb class seems buggy, the childactorcomponent can’t be rotated/moved in the character BP viewport, and everytime I hit compile/tick and untick skeletal mesh visible it duplicate the display of skeletalmesh in the character BP viewport, also when I hit play it doesn’t show the childactorcomponent’s skeletal mesh in the scene which it should be attached to my character BP mesh. =/

Hmm, that doesn’t sound good. Afraid I can’t help you with that, I’ve never actually used the child actor component so have no idea why it would be doing that. Sorry, hope you get it sorted.