title: Unity - Using a rigidbody for motorcycle - how do I turn?
body: <p>I'm new to Unity and rigidbodies, and I thought I'd learn by trying to make a 3D Tron Light-cycle game. I've made my player vehicle using a combination of cylinders, spheres, and rectangles, seen below:</p>
  
  <p><a href="https://i.stack.imgur.com/7H6eC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7H6eC.png" alt="enter image description here"></a></p>
  
  <p>I used a rigid body on the elongated sphere, and used the following code:</p>
  
  <pre><code>public float accel = 1.0f;    
  // Use this for initialization
  void Start () {
      cycleSphere = GetComponent&lt;Rigidbody&gt;();
  }
  
  void FixedUpdate () {
      cycleSphere.velocity = Vector3.forward * accel;
  }
  </code></pre>
  
  <p>That moves the vehicle forwards. I'm not sure if there's a better way to do this, but if there is, please do say so.</p>
  
  <p>I've attached the Main camera to the vehicle, and disabled X rotation to prevent it and the camera from rolling.</p>
  
  <p>Now I would like to get it to turn by pressing the A and D buttons. Unlike the 90 degree turning of the original Tron light-cycles, I wanted it to turn like a regular vehicle.</p>
  
  <p>So I tried this:</p>
  
  <pre><code>void Update () {
      if (Input.GetKey (KeyCode.A)) {
          turning = true;
          turnAnglePerFixedUpdate -= turnRateAngle;
      } else if (Input.GetKey (KeyCode.D)) {
          turning = true;
          turnAnglePerFixedUpdate += turnRateAngle;
      } else {
          turning = false;
      }
  }
  
  void FixedUpdate () {
      float mag = cycleSphere.velocity.magnitude;
      if (!turning) {
          Quaternion quat = Quaternion.AngleAxis (turnAnglePerFixedUpdate, transform.up);// * transform.rotation;
           cycleSphere.MoveRotation (quat);
      } 
      cycleSphere.velocity = Vector3.forward * accel;
  }
  </code></pre>
  
  <p>While the above code does rotate the vehicle, it still moves in the last direction it was in - it behaves more like a tank turret. Worse, pressing either A or D too much would cause it to rotate in the desired direction and, after a short while, go nuts, rotating this way and that, taking the camera with it.</p>
  
  <p><a href="https://i.stack.imgur.com/ep1YN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ep1YN.png" alt="enter image description here"></a></p>
  
  <p>What did I do wrong and how can I fix it?</p>