Made a script library example for moving players on a grid.
There’s 2 different ways of movement on a fixed grid:
- input buffer (WASD input): this way of input is good for movement like in Crossy Road, Bomberman or Frogger. You can set the maximum amount of queued inputs to have more direct input. Holding down a key keeps moving your unit in that direction until you let go of the key.
- continuous movement (Arrow Keys): use this for games with continuous movement like Pacman or Snake. The unit will constantly move forward until it hits a wall. There is also code to disable 180 degree turns. Inputs are registered before the unit completes their current move, so there’s some buffer to the movement system.
Tweaks:
- press M to change movement mode between move, teleport and command mode
- you can adjust the movement speed by adjusting
currentTickTimer
settings in theperformMove
script. - maximum input buffer amount (global var maxQueueLength)
- you can change tile dimensions (
You can test it out here. Press WASD keys
for regular movement and arrow keys
for pacman style movement. P
teleports you to the pacman map.