Hi guys!
I have a question about spawning actors using C++.
Here is my code:
Header:
//Spawner Stuff
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = “Testing”);
TSubclassOf<AActor> RHC_Spawn;
UFUNCTION(BlueprintCallable, Category = “Spawn_Function”)
void SpawnRHConstraint();
CPP:
void ASpawner::SpawnRHConstraint()
{
FActorSpawnParameters SpawnParams;
AActor* SpawnedActorRef = GetWorld()->SpawnActor<AActor>(RHC_Spawn, FVector(0.0f, 0.0f, 0.0f), FRotator(0.0f, 0.0f, 0.0f), SpawnParams); //Location, Rotation
}
Now, this code works but there is one thing I do not like. For it to work, I have to go in to my Blueprint editor and set RHC_Spawn to the class that I want to spawn. Check the picture.
Is there a way to do this assignment in C++. I have searched and searched and searched and have not found an answer on this. Using the editor to do the assignment is not the end of the world but if it is possible I do prefer C++. Is there a way?
Thank you in advance.