# How do I check where my character is moving before he moves there?

I am starting an isometric game that works kinda like pokemon, moving through a space of blocks, but in 3D. I already programed the basic movement, so that the player is able to move the character in the x and z-axis.

In simple words, the problem is that when the player presses a key to move, I need to check the block where the character is moving before he moves, so that I can check if it has another object over it (through a tag in the block called Collision) and that the altitude difference between this block and the current character position isn’t too big so that he can walk onto it. Also, if this conditions are met I need to see how much in the y-axis the character needs to move so that he doesn’t go through the floor or flies.

here’s the function (C#) of the movement:

``````	void MovementManagement ()
{
string dir = "n"; /*direction in which the character is moving: u: up
d: down
r: right
l: left
and combinations.
*/

if (canMove && !isMoving) //Checks if the character isn't moving
{
//When the player presses a key, we will add a direction to the position
//using Vector3."anydirection" will add 1 to that direction.
//also we'll check if we are at the new position, so that the player can
//only move if he is already in a tile.

if 		(Input.GetKey (KeyCode.W) && tr.position == pos)
{
dir = "u";
pos += 2 * Vector3.right;
}
else if (Input.GetKey (KeyCode.S) && tr.position == pos)
{
dir = "d";
pos += 2 * Vector3.left;
}
else if (Input.GetKey (KeyCode.D) && tr.position == pos)
{
dir = "r";
pos += 2 * Vector3.back;
}
else if (Input.GetKey (KeyCode.A) && tr.position == pos)
{
dir = "l";
pos += 2 * Vector3.forward;
}

//if (!the block where the character is moving has the tag 'Collision')
//{
//if (dy < 0.5f) walk0
//else if (dy < 1f) walk1
//else if (dy < 1.5f) climb
//else don't allow movement
isMoving = true; //tells the other scripts that the character is moving.

transform.position = Vector3.MoveTowards (transform.position, pos, Time.deltaTime * speed);

isMoving = false; //tells the other scripts that the character stopped moving.
//}
}
}
``````

And here’s an image of how the demo map works, to illustrate the discrete “movement by blocks”, in case I wasn’t clear enough.