How to SpawnActor with differnet staticmesh?


I’d like to Spawn the actor for the first instance with CUBE mesh, second instance with SPHERE mesh. Is there any method to call SpawnActor function with static mesh parameter. I’ve been using the below code for spawn the actor. Any ideas/samples would be great helpful.

In BeginPlay()

GetWorld()->SpawnActor<MyActor>(Location, FRotator(0,0,0));

You could use SpawnActorDeferred and set properties on it before the spawning has finished. ShooterGame has an example of how to use it.

I’ve the SpawnActorDeferred function, but not able to get the result. Could you please share some sample code for better understanding.