C++ How to spawn something from GameInfo

In a class extending Character I use UGameplayStatics::BeginSpawningActorFromClass to spawn something.

UGameplayStatics doesn’t seem available in a class extending AGameInfo.

Dear Michael,

Why do you need to use BeginSpawning, avoiding running constructor script, instead of doing:

(UClass*) ActorBluePrint; //value set via BP or constructor


//Spawninfo
FActorSpawnParameters SpawnInfo;
		
//SpawnInfo.bNoCollisionFail = true;
SpawnInfo.Owner = this; //assuming inside player controller class or some similar class
	
//spawn creature
AActorBaseClass* NewCreature = 
	GetWorld()->SpawnActor(ActorBluePrint, loc, rot,SpawnInfo );

I’ve always enjoyed your posts Michael!

:slight_smile:

Rama

I ended up doing this last night. I used the begin spawning on a particle effect before, so I guess I was just trying to do it the same way I had.

I see it’s not a problem, but I was spawning from GameInfo.