Download

How can I spawn a sphere at run time without blueprints Unreal 4.7?

Alright, I may just be super idiotic or have a hard time understanding the class system but I cannot figure out how to create any actor or spawn any actor in the scene. I can do it in blueprints, but the Documents that I have looked at are all obsolete and when I ask I get a response like I should already know how to do it.

Can someone please explain it for me because I have been trying to understand this for a while

Thanks,

If you’re trying to spawn something, you just need to use the function you provided by Epic! This function is located inside your World class, so you have to use GetWorld() first!


GetWorld()->SpawnActor<ClassNameHere>(YourClass::StaticClass(),FVector LocationToSpawnAt,FRotator RotationToSpawnWith)

that’s the most basic way, but there are some optional extra parameters you can pass in too if need be!

example, if i put this in my controller…


GetWorld()->SpawnActor<AActor>(APawn::StaticClass(),GetActorLocation(),GetActorRotation()

that would spawn a Pawn (which is a child of Actor) exactly where my Controller is located.