I have an object with a class variable (UClass* MyClass;), and I would like to spawn an actor from this class. How can I go about this? It would be optimal to have some sort of equivalent to this blueprint function.
I’d want it to specifically use UClass* because this will be a variable exposed as a spawn parameter, where as soon as this actor is spawned, it will spawn another actor from MyClass.
Whoops, just tried it’s asking for pointer to rotation and location when using in this way. this should work:
UClass* MyClassToSpawn;
FVector Location(0.0f, 0.0f, 0.0f);
FRotator Rotation(0.0f, 0.0f, 0.0f);
FActorSpawnParameters SpawnInfo;
GetWorld()->SpawnActor(MyClassToSpawn, &Location, &Rotation, SpawnInfo);