- Home /
Flight script problem
Hey having a small problem with my flight script, it's pretty basic, but when I rotate left or right on the Z, 90 degreas, I can no longer rotate on the X at all. It's become a problem with the flight script, because that's how it turns.
If you can't visualize the problem, imagine a plane banking left and unable to curve outwards to turn.
Coded in C#
using UnityEngine;
using System.Collections;
public class PlaneMovement : MonoBehaviour {
public float fThrust;
public float rLeft;
public float rRight;
public float rUp;
public float rDown;
// Update is called once per frame
void Update () {
if(Input.GetKey(KeyCode.Space))
{
rigidbody.AddRelativeForce(0,0,-fThrust);
}
if(Input.GetKey(KeyCode.A))
{
rigidbody.AddRelativeTorque(0,0,-rLeft);
}
if(Input.GetKey(KeyCode.D))
{
rigidbody.AddRelativeTorque(0,0,rRight);
}
if(Input.GetKey(KeyCode.W))
{
rigidbody.AddRelativeTorque(-rUp,0,0);
}
if(Input.GetKey(KeyCode.S))
{
rigidbody.AddRelativeTorque(rDown,0,0);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Flight mechanics 2D, variables vs forces 1 Answer
Gui text script - help 1 Answer
Unity Coroutine problem 1 Answer
Problem with script 1 Answer
ArgumentOutOfRangeException: Argument is out of range. Parameter name: index System. 0 Answers