Hello,
I am trying to make a 2D game.
But i can’t find out how you can make a player move one distance at a time.
By that I mean when you press the right arrow key your character moves form x to x + 1, then waites and if you are still holding it you move again 1 ‘block’ to the right. So you are always above a block. Excpect when you are moving. I hope you understand.
Not sure what you mean exactly, but I think this helps. This example uses WaitForSeconds function which pauses the Update for the delay given as the parameter. You can surely figure out the rest of the code.
private var moveCheck:boolean = true;
private var delay:int = 2;
function Update() {
if (moveCheck)
Move();
}
function Move() {
moveCheck = false;
yield WaitForSeconds(delay);
//Put code for movement here
moveCheck = true;
}
Here is a starting point. I wrote it as an answer to another question, but I think it gives you the motion you are looking for. Attach it to a cube and use the arrow keys to move.