# Move character forward depending on rotation

I got the ray to tell when it cant move working, I have rotation working, I even have the ray rotating correctly. I just cannot think of how to get the character to move forward by 1 unit in the direction it’s facing.

``````if (Input.anyKeyDown)
{
var FowardRayDistance = 0f;

Vector2 fwd = transform.TransformDirection(Vector2.up);
Vector2 bwd = transform.TransformDirection(Vector2.down);

//Foward Ray
while (FowardRayDistance < maxFowardCheckDistance)
{
RaycastHit2D FHit = Physics2D.Raycast(transform.position, fwd, FowardRayDistance);
RaycastHit2D hit = Physics2D.Raycast(transform.position, bwd, FowardRayDistance);

if (FHit)
{
if (Input.GetKeyDown(KeyCode.W) && FowardRayDistance > 1)
{

}
else if (Input.GetKeyDown(KeyCode.Space))
{
Debug.Log("hit: " + FHit.collider.name + "| at: " + FowardRayDistance);
}

FowardRayDistance = maxFowardCheckDistance;
}
else
{
FowardRayDistance += 1f;
}
}
}
``````

The `if (Input.GetKeyDown(KeyCode.W) && FowardRayDistance > 1)` area is where i know the movement part will go i just dont know what to put there.

@LordBitcube, you want to move in specific direction, just multiply the direction by the distance you want to move (in your case 1 Unity unit? Then no need to even multiply) and add it to your current position.

it looks like you have already calculated forward, and assuming your not working with a Rigidbody, then: transform.position = transform.position + fwd

I am quite confused on how that works but it does. I suppose Unity just assumes when adding position forward just add by one by default.

Works perfectly though thank you so much