Crash loading map in the editor

Hey!

I have a problem when I load a map in the editor,it crashes the editor at: (SceneComponent.cpp line 842)

#if WITH_EDITORONLY_DATA
							// If we are in the middle of a transaction it isn't entirely unexpected that an AttachParent/AttachChildren pairing is wrong
							if (!ensure(GIsTransacting))
#endif

It looks like it is crashing when it tries to clear the old map and load the new one.

I think that the problem comes from a few AttachTo that I make:

AAICharacter::AAICharacter(const FObjectInitializer &ObjectInitializer)
{
  //Initialize components
  mainRoot = ObjectInitializer.CreateDefaultSubobject<USceneComponent>(this ,TEXT("MainRoot"));
  weaponHolder = ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("WeaponHolder"));
  mainWeapon = ObjectInitializer.CreateDefaultSubobject<UWeapon>(this,TEXT("MainWeapon"));
 
  mainWeapon->AttachTo(weaponHolder);
  weaponHolder->AttachTo(mainRoot);
  mainRoot->AttachTo(RootComponent);
}

What could be the issue?

Im using Unreal 4.11.2 and I´m launching the project from visual studio.

.

Hey piluve-

Can you post the callstack and log files from the crash for additional information? If you believe the crash is caused by an AttachTo() statement, you can try to comment them out one at a time and run again to see if any are the issue.

Hey!

Here you have a pic of the callstack:


I´ve also tried to remove 2 of the AttachTo() and it does work.

It appears that the crash is caused by a specific actor in the level. Does the crash occur if you PIE with the affected level or only when traveling to that level from a different one? If possible, you can narrow down which actor is causing the issue by creating a copy of the level and removing actors from it and traveling to it.

Additionally, looking at the order of your AttachTo() calls, I would try reordering them so that the component is attached before you try attaching something else to it (so order it as 3,2,1 instead of 1,2,3).

I “solved” it by using AttachParent instead of the AttachTo() method.