title: local movement on rigidbody sphere with the mouse and keyboard
body: <p>So i have completed the Roll a ball tutorial from Unity that is a little game that uses a sphere with a rigidbody applied to it with some basic movement script found <a href="http://unity3d.com/learn/tutorials/projects/roll-a-ball" rel="nofollow">here</a>.</p>
  
  <p>What i want now is to take it a step further and introduce a somewhat more advanced movement script which also takes mouse input into play.</p>
  
  <p>What i am trying to achieve is so to add force based on the local axis, so if i i move the mouse left the ball turns and the force is added in that direction. Let me show what code i have come up with (added to a simple sphere with rigidbody applied):</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class playerController : MonoBehaviour {
  
      public float turnSpeed = 2.0f;
      public float moveSpeed = 250.0f;
  
      void FixedUpdate() {
  
          float h = turnSpeed * Input.GetAxis("Mouse X");
          transform.Rotate(0, h, 0);
  
          float moveHorizontal = Input.GetAxis("Horizontal");
          float moveVertical = Input.GetAxis("Vertical");
          Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
          rigidbody.AddForce(movement * moveSpeed * Time.deltaTime);
  
      }
  
  }
  </code></pre>
  
  <p>Ok so what is happening is that the ball is turning when i move the mouse, and the ball is rolling if i use the arrowkeys, but what i'm not managing to figure out after some trial and error is to get the ball moving in the direction it is turning.</p>
  
  <p>How would you approach this particular scenario? Any help is as always much appreciated guys.</p>