Spawned actor doesn't update children location (pivot disconnected).

Hi,

I am spawning an actor with two components attached. Here is the constructor:

RootScene = CreateDefaultSubobject<USceneComponent>(TEXT("MyRootScene"));
RootComponent = RootScene;
MyMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MyMesh"));
MyMesh->SetupAttachment(RootComponent);

And I am spawning the actor in another actor’s constructor. Then, I am changing the location of the spawned actor in C++. The problem is, after setting this new location, actor is displaced, but static mesh connected to the actor is not. The same when I try to move the spawned actor in the editor, pivot is moving but not the components.

When I press ctrl-z (undo) just after spawn, the actor’s pivot snaps back to the static mesh and then it all moves together, as intended.

I assume I’m missing a step and the editor is confused, but resetting the actor, resetting the owned components and resetting the BlueprintCreatedComponents doesn’t fix it. Registering the components of this actor at any given point throws an exception.

Any suggestions?