Spawning Static Mesh Actors at runtime

You can spawn stationary actors at runtime. The most common way to spawn any actor is:

AMyActor* NewMyActor  = GetWorld()->SpawnActor<AMyActor>();

So, too answer your question, add:

AStaticMeshActor* NewMesh = GetWorld()->SpawnActor<AStaticMeshActor>(FVector(0, 0, 0), FRotator(0, 0, 0));
NewMesh->SetStaticMesh(Soil);

The Vector is the location and the Rotator is the rotation.
If you are spawning a subclass of AStaticMeshActor, just substitute “AStaticMeshActor” for “AYourStaticMeshActor

Hope this helps

1 Like