I am able to use SpawnActor to spawn the actor I want, but it spawns with the default values for the class. In order to give the actor the values it needs, I thought I should use FActorSpawnParameters and give it a template from another instance of the class that’s already in the scene. Here’s the code:
//.cpp
void ANaziSpawner::BeginPlay()
{
FActorSpawnParameters params;
params.Template = templateNazi;
params.bAllowDuringConstructionScript = true;
ANazi* spawnedNazi = ()->SpawnActor<ANazi>(templateNazi->GetClass(), GetActorLocation(), GetActorRotation(), params);
}
//.h
UPROPERTY(EditAnywhere)
AActor* templateNazi;
If I take out the params in SpawnActor, it works completely smoothly. As is, it compiles but causes the client to crash when I try to play. I can find a way to work without using FActorSpawnParameters in the SpawnActor, but it would be very useful if I can get this to work.