Problem with inheriting USceneComponent

Hi,

I want to create my own component that I can drag&drop to my actors. For this I inherit from USceneComponent. To show the component I create some sub components (e.g. StaticMeshComponents) like that:



//Constructor(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)

CompassMesh = CreateDefaultSubobject<UStaticMeshComponent>("CompassMeshComponent");
CompassMesh->AttachTo(this);

//...


It was working fine. Then I added Steam multiplayer and needed to play in Standalone mode instead of PIE. I figured out that playing in Standalone gives me an instant crash. In the logs I got the following message:

For this problem I found following answer:

Unfortunately I have no idea what I need to do… I could taking a random number, cast to string and use that as a name. But this makes me feeling very bad since random != unique.

Can you help me?

TL;DR
How to fix “Gamethread hitch waiting for resource cleanup on a UObject (…) overwrite.” on class inherited from USceneComponent?

It seems to be caused by name collisions, objects with the same name. More details here: [C++] SpawnActor Bug - C++ - Epic Developer Community Forums

3 Likes

Same here, I spawned Spline Mesh components dynamically in a loop and by simply not specifying the FName Name parameter, the deluge of warnings disappeared:

USplineMeshComponent* SplineMesh = NewObject<USplineMeshComponent>(InParent);

The docs say

the name for the new object. If not specified, the object will be given a transient name via MakeUniqueObjectName

cf. NewObject | Unreal Engine Documentation