Movement and forces
There are three ways to move an object.
1. Behaviors (the simplest)
Platform, 8 Direction, Bullet, Follow, Move to… come with movement built in. See Behaviors.
2. Change the position
The object's Position action sets or adds values on X and Y.
| Conditions | Actions |
|---|---|
Keyboard: Key pressed Right |
Ship X position + 300 * TimeDelta() |
TimeDelta() keeps the speed the same on any computer.
3. Forces
A force pushes the object continuously, and several forces add up. Use the actions under Movement using forces:
| Action | What for |
|---|---|
| Add a force (angle) | Push in a direction, given in degrees, with a speed. |
| Add a force to move toward an object | Chase another object. |
| Add a force to move toward a position | Go to a point. |
| Stop the object | Reset every force. |
Angles: 0 is right, 90 is down, 180 is left and 270 is up.
A shot leaving the player
| Conditions | Actions |
|---|---|
Keyboard: Key just pressed Space |
Create an object Shot at Player.X(), Player.Y() Shot Add a force (angle) 0, 500 |
An enemy that chases the player
| Conditions | Actions |
|---|---|
| (none) | Enemy Add a force to move toward an object Player, 120 |
Tip: since the event runs every frame, prefer the "move toward" force action over repeating position maths.
Rotating
The Rotate action turns the object at a speed in degrees per second, and Rotate toward another object makes a turret aim at its target.
Gravity and physics
For realistic falls and collisions (blocks, balls), add the Physics behavior to the object, or Platform with Physics for physics platformers.