# Diagonal moving is faster .Help in solving a bug!

So i wrote script that moves and rotates my ship,everything works but when moving diagonal its moving faster.Thanks.

``````        if(movingUp == true)
{
transform.position = new Vector3(transform.position.x,transform.position.y + speed,transform.position.z);

if(movingLeft == true)
transform.rotation =

if(movingRight == true)
transform.rotation =

if(movingRight == false && movingLeft == false)
transform.rotation = Quaternion.Slerp(transform.rotation,Quaternion.Euler(90,0,0),rotationSpeed*Time.deltaTime);

}
if(movingDown == true)
{
transform.position = new Vector3(transform.position.x,transform.position.y - speed,transform.position.z);

if(movingRight == false && movingLeft == false)
transform.rotation =

if(movingLeft == true)
transform.rotation =

if(movingRight == true)
transform.rotation =

}

if(movingRight == true)
{
transform.position = new Vector3(transform.position.x + speed,transform.position.y ,transform.position.z);

if(movingUp == false && movingDown == false)
transform.rotation =

}
if(movingLeft == true)
{
transform.position = new Vector3(transform.position.x - speed,transform.position.y,transform.position.z);

if(movingUp == false && movingDown == false)
transform.rotation =
}
``````

This is stub without much to go on but essentially you want to see if the player is pressing both a horizontal and a vertical consecutively and if so apply something like speed = speed * .75 or whatever seems appropriate.