Runtime error while spawning actor

Hello there!

I have a problem, would like to insert a simple step into spawning actors at runtime. i want a class responsible for spawning, but not knowing the type of what to spawn.

AActor *AObjectBuilder::CreateDefaultBaseObject(UClass *Inclass)
	AActor *temp = ()->SpawnActor(Inclass);
	return temp;

then i want to use an instance of that to spawn like this:

AObjectBuilder test;
TSubclassOf<AActor> elem = AMyCube::StaticClass();
AActor* temp = test.CreateDefaultBaseObject(elem);

if i do it this way, the engine crashes… any ideas?

thanks in advance:)

Check logs, Saved/Logs in your project directory