Download

Spawning a Movable Actor (c++ only)

Like the title says, I’m having trouble spawning a movable actor in c++. Right now I have an asteroid spawning in my GameMode cpp using this:

Asteroid = World->SpawnActor<AAsteroidObject>(AAsteroidObject::StaticClass(), AsteroidLocation, AsteroidRotation);

The goal is to have a rotating asteroid that will be landed on. As of right now the asteroid reads changes in rotation as specified in the code, but it won’t actually move in the engine. I’ve looked into using AI controller and making my asteroid an AI Pawn but I’m wondering if its really necessary to make such an extensive code for a simple rotating asteroid. Please help.

You can give the Asteroid a script then use AActor::AddActorLocalRotation to rotate it on itsTick event or through a timer.
Then you just need to call SpawnActor once to spawn the self-rotating Asteroid.