Actor Parenting Issue (C++ -> World Outliner)

I have two custom C++ actors that I am creating from code that show up in the world and World Outliner.

However, I’m trying to get things more hierarchical.

I’m trying to add ubody to ubiped as a child actor in the Outliner, but it isn’t working.

ubody->AttachToActor( ubiped, FAttachmentTransformRules::KeepWorldTransform );

What’s the proper way to change an actor’s parent in the scene from C++?

It probably has attached, but because you’re using ''FAttachmentTransformRules::KeepWorldTransform" the object you are attaching stays where it is.

If you want the object to move to the thing it’s been attached to, use SnapToTarget instead.

I tried SnapToTarget without success.

I mean in the World Outliner. This is how it is currently…

But I’m trying to get the _head to be shown as a child of the BipedActor. Like these…

My initial question is why are you assembling objects in the scene outliner instead of blueprinting them? I can understand if you’re parenting a wall to a floor or something, but parenting a head to a body sounds like something that should be done in asset form, not in the level directly.

I can’t tell you why it’s not attaching to be honest then, it’s going to be something specific to your setup.

the world outlier also has filters that you can change to show “hidden actors” and other such things sometimes you need to change filters to see components.

Also components can be weird. some components ive found out will only properly work as the root component.
and certain attributes get cleared after the constructor so you have to move them to begin play instead.

The scene is actually being built up from C++, it’s a port of an OpenGL/Bullet Physics game.

The game basically builds separate rigidbody objects/actors, connects them with constraints, and then creates a poseable mesh to actually have the skinned mesh geometry.

Doesn’t solve my question, but these were some really helpful tips, especially the filter, thanks!

Are they spawning at the correct xyz transform? just not attaching ?
and when are you attaching them? after its been created w a reference or during the begin play?

Yeah, everything is correct in world/xyz space transform. Just not attaching as far as the World Outliner reports. I’m trying to attach them just after they have been creation.

Try creating the actor in BeginPlay of the parent actor (ubiped):

1st step is to spawn you child actor inside your parent actor, beginplay is a good spot
2nd step is to attach with a transform option, snap or keep or world, then set the x,y,z if needed or skip that part.

FActorSpawnParameters SpawnParams;
SpawnParams.Owner = this;
ubody = World->SpawnActor<AActor>(ubody_class, FVector(0.f), FRotator(0.f), SpawnParams);
ubody->AttachToActor(this, FAttachmentTransformRules::KeepRelativeTransform);
ubody->SetActorRelativeLocation(FVector(0)); //spawn at origin point of parent actor