Crossy Road-Like Controls

This is a pretty simple post. I just need a list of things I should know to make Crossy Road-Like controls that move the player when they press W A S or D.

I started by disabling the player’s controls. Now I’m stuck.

Crossy road is a grid/tile-based movement system, so you will want to define area the player can move as a multiple of some value, probably 4 studs per move from what I can tell of the player-to-world scale in crossy road. Lock the player to this grid by placing them in a cell.

Define your own controls for WASD with a debounce in each such that there’s no key overlap possible, since you want explicitly 4-way movement not 8-way (diagonals). So, when a player presses W, you would tween their HumanoidRootPart (using :MoveTo() pathfinding will be problematic with moving obstacles) to their position plus an offset vector of however large your tiles are (say, if forward-axis is on X, you would +Vector3.new(4,0,0) )

Your controls might look something like this:
W: +(4,0,0) (vector)
A: +(0,0,4)
S: -(4,0,0)
D: -(0,0,4)

Make the thread yield until they complete their move before releasing the debounce. Up to you if you want to program it to loop a single move so long as the key is still held or not.

You’ll limit how far they can move with numeric boundaries rather than physical, by making a comparison of the movement they’re attempting to make to your limits (say you define the minimum x to -40 and the max x to 40, make sure they can’t move to -44 or 44)

2 Likes

Not sure but you could use the moveto() function and then use the Look/Right vector of HumanoidRootPart to move the character.

1 Like