Object Initialization, Crash UEditor

Hi! I have problem, please help me solve this.
I have AClass inherited from AActor. I need init this class in AMyPlayerController. If i init this object by this method:

AClass Class = new AClass*

then UEditor have crash after hot reload :\ What’s the problem? Thanks!

After four hours of torment, i solved this problem :cool:

Instead of:
AMyClass Class = new AMyClass;*

Need:
AMyClass Class = (AMyClass*)AMyClass::StaticClass()->GetDefaultObject();*

If your object is an actor (as most are), you can also use something like this:



FActorSpawnParameters p;
p.bNoCollisionFail = true;
			
AMyActor* spawningActor = World->SpawnActor<AMyActor>(AMyActor::StaticClass(), FVector::ZeroVector, FRotator::ZeroRotator, p);


This is incredibly confusing without proper context. Where is this “initialization” being done? Do you need a class or an instance? There is no such thing as GetDefaultClass on a UClass, only GetDefaultObject, do you understand the ramifications of using the default object?