1. Home
  2. Docs
  3. Game Factory Documentatio...
  4. Coding
  5. Moving in actor space

Moving in actor space

We already saw moveForward() in the last section. Now we can be more precise about it: moveForward() moves forward in actor space, so the actor will go in the direction that it’s looking at.

Just like we have moveForward(), we also have moveBackward(), moveRight(), moveLeft(), moveUp() and moveDown(). Those are all in actor space, so relative to where the actor is looking.

Let’s combine spin() with moveForward now for an interesting effect:

  // My script

  export function onTick() {
    spin(1);
    moveForward(1);
  }
  

What do you get now? Yes, a slime that runs around in circles:

Why does this happen? Think about what happens on every tick: the slime turns a little bit, then takes a tiny step forward. The fact that it’s turning means that “forward” is different every time, so the net effect is that it runs around in a circle. Neat, right?

How can we help?

Search this website Type then hit enter to search