How to detect object go up or down?

Hi
I have an airplane object and I want to when my airplane go up speed increase and when go down speed decrease or some times when it change direction more than a number (30 degree or …) to left or right the speed decrease, but don’t know how can detect the direction of moving ?
I want to do this work just by code.
thanks

You could try changing the lines 68 to 74 to this:

if(Input.GetKey(KeyCode.Q))
{
  transform.Rotate(0,-Acceleration*Time.deltaTime,0);

  //reduce the speed slighlty when the player makes the plane rotate
  rigidbody.velocity.z -= Acceleration * Time.deltaTime;
}

if(Input.GetKey(KeyCode.E))
{
  transform.Rotate(0,Acceleration*Time.deltaTime,0);

  //reduce the speed slighlty when the player makes the plane rotate
  rigidbody.velocity.z -= Acceleration * Time.deltaTime;
}

If this works then you might want to add a check to see if the forward speed is greater than a certain amount so the plane won’t come to a full stop in mid-air :wink: