I am trying to make an AirCraft that moves, and when you turn left or right, it leans in that direction smoothly, and when you release the turn key, it returns to its original rotation (smoothly again, but a bit faster).
So far I have this, and it only rotates the plane a little, and doesn’t return to its original rotation. Whats wrong?
if (Input.GetKey(KeyCode.LeftArrow)) {
transform.Translate (-1f, 0f, 0f);
if (leftLeaning > 0.0f) {
transform.Rotate(0f, 0f, 1.5f);
leftLeaning--;
}
}
if (!Input.GetKey(KeyCode.LeftArrow)) {
if (leftLeaning <= 1.0f) {
transform.Rotate(0f, 0f, 0.2f);
leftLeaning++;
}
}
Also I don’t know how much in float numbers is 90 degrees and 0 degrees.