[4.12.5] Wrong component hierarchy order

I’m having this issue where instanced blueprints have the wrong order in the component hierarchy as well as incorrect transforms (probably caused by the incorrectly ordered components) until I reload the same map again.

I think it’s strange that only reloading the same map seems to correct the issue. As if there is some missing step in the initial map-load when opening the editor compared to opening a new map (in this case the same map).

This started happening after I added the SphereComponent as the new root of the actor through C++. The instances in the map had already been placed by then.

##The current object structure

###C++

  • [Root] Sphere Component
  • Paper Sprite Component
  • Paper Flipbook Component

###Instance BEFORE map re-reload

  • [Root] Paper Sprite Component
  • Sphere Component
  • Paper Flipbook Component

###Instance AFTER map re-reload (Correct components & transform)

  • [Root] Sphere Component
  • Paper Sprite Component
  • Paper Flipbook Component

##Before adding the Sphere Component as the new Root

  • [Root] Paper Sprite Component
  • Paper Flipbook Component

~Per “” Johansson

Hey -

Are the Paper Sprite Component and Paper Flipbook Component added through code or the editor? Can you provide the code setup for your blueprint? Does this only occur with instances of a specific blueprint or are you able to reproduce this with the same setup in other blueprints? When the Sphere Component was added, was the code compiled with the editor closed or while the editor was open?

Hi ,

All components are added through C++ code and I made sure to close down the editor between adding components.

This is the code I use to setup the components in the constructor.

It was when I added the SphereRoot that the issues started appearing.

SphereRoot = CreateDefaultSubobject<USphereComponent>(TEXT("SphereRoot"));
	RootComponent = SphereRoot;

	m_sprite = CreateDefaultSubobject<UPaperSpriteComponent>(TEXT("Sprite"));
	m_sprite->SetWorldRotation(FRotator(0.0f, 0.0f, -90.0f));
	m_sprite->SetupAttachment(RootComponent);

	m_animatedSprite = CreateDefaultSubobject<UPaperFlipbookComponent>(TEXT("AnimatedSprite"));
	m_animatedSprite->SetWorldRotation(FRotator(0.0f, 0.0f, -90.0f));
	m_animatedSprite->SetupAttachment(RootComponent);

Can you confirm that I am following the same steps as you.

  • I copied the code you provided into an actor class with proper includes and pointer declarations.
  • I commented out the declaration and setup for the SphereRoot and compiled.
  • In the editor I added a few instances of the blueprint based on my class.
  • I saved everything and closed the editor
  • In code I uncommented the SphereRoot lines and compiled again

When I reopened the project and select one of the instances in the level, the hierarchy is shown as SphereRoot->m_sprite->m_animatedSprite. Closing and reopening the project did not affect the hierarchy of any of my placed instances. Can you provide further details about your setup?

Yeah, that’s the same steps. I’ve again granted you only access to the repository so that you can investigate more easily. I think that it’s difficult even finding some repro for this issue since it’s so case-dependent in my experience.

Hey -

When I opened the project the various BP instances had the expected hierarchy (SphereComponent->Sprite Component->Flipbook Component) and their orientation was towards the Z axis. There was no change after reloading the level or closing / reopening the project. Adding a new instance of the blueprint did not have any affect after closing / reopening the project either. Let me know if you’re able to reproduce the hierarchy issue in a new project and if so, please include the steps used.

Hey -

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will follow up.