i want my object to only be able to move forward on the z axis, which works until i try and add in a roll rotation for a barrel roll in which the when i rotate to move up and down it can travel in the x axis. if that makes sense? anyway i can keep it moving and rotating along the z but have a roll function too?
heres my script so far :
"
public class PlanePilot : MonoBehaviour {
public float speed = 90.0f;
public float turnSpeed = 10f;
public float rollSpeed = 10f;
public Rigidbody rb;
public float turnInput;
public float speedInput;
public float roll;
void Start() {
rb = GetComponent();
}
void Update ()
{
speedInput = Input.GetAxis (“Jump”);
turnInput = Input.GetAxis (“Horizontal”);
roll = Input.GetAxis (“Vertical”);
}
void FixedUpdate() {
rb.AddRelativeForce(new Vector3(0.0f, 0.0f, speedInput * speed));
rb.AddRelativeTorque(new Vector3(turnInput * turnSpeed, 0.0f, 0.0f));
transform.Rotate (new Vector3(0.0f, 0.0f, roll * rollSpeed));
}
}
"