My Game is crashing sometimes despite `IsValid` with UObject.Name="None". What am I doing wrong? Wrong smart Pointer?

In this case I was referring to code that executes to initialize global/static variables at C++ initialization (which is normally called the CRT initialization afaik).


The first parameter of NewObject is for the Outer (aka. parent/owner of the new object), not the class. Here you are spawning the native class UObjectSpawner where myFishBlueprint is not set, instead of spawning whatever ObjectSpawnerBlueprint points to.
Should be like this :

myObjectSpawner = NewObject<UObjectSpawner>(this, ObjectSpawnerBlueprint);

Is there any particular reason you are using UObject for this ?
Your spawner object shares same lifecycle as gamemode, and needs a world to live in and spawn objects.
Sounds like an AActor would be more fitting.

2 Likes