I’m trying to write a generic function that, when handed an Actor (or a child class/blueprint thereof), will spawn that actor at some arbitrary location:
AActor* USpawnManager::SpawnActor(AActor* ActorToSpawn, FVector SpawnLocation){
if (World != nullptr && ActorToSpawn != nullptr){
AActor* tempActor = World->SpawnActor(ActorToSpawn, &SpawnLocation);
return tempActor;
}
return nullptr;
}
This looks right to me, but it throws an error which makes me assume my syntax is wrong: "‘AActor *UWorld::SpawnActor(UClass *,const FTransform *,const FActorSpawnParameters &)’ : cannot convert argument 1 from ‘AActor *’ to ‘UClass *’ ". This makes it seem like it wants a uclass instead of an actor, but if I try giving it something like Cast(ActorToSpawn), the entire program crashes. Am I making an obvious mistake, or is GetWorld()->SpawnActor not the right way to be spawning actors in the first place?