title: Unity3D controlling a ball
body: <p>In Unity3D, I'm working on simply controlling a ball. My goals are as follows:</p>
  
  <ul>
  <li>Allow the ball to rotate</li>
  <li>Move in the direction the ball is facing</li>
  <li>Ensure the ball is visually rotating as the ball is moving</li>
  </ul>
  
  <p>What I am attempting to do is almost accomplished with this <code>character controller</code> script I wrote:</p>
  
  <pre><code>transform.Rotate (new Vector3(-Input.GetAxis ("Horizontal") * rotationSpeed, 0, 0));
  Vector3 forward = Input.GetAxis ("Vertical") * transform.forward * moveSpeed;
  
  controller.Move (forward);
  controller.SimpleMove (Physics.gravity);
  </code></pre>
  
  <p>My problem with this script is that the ball does not visually "roll".</p>
  
  <p>I attempted to solve this by using a <code>Rigidbody</code>:</p>
  
  <pre><code>float movementHorizontal = Input.GetAxis("Horizontal");
  float movementVertical = Input.GetAxis("Vertical");
  
  Vector3 movementVector = new Vector3(movementHorizontal, 0.0f, movementVertical);
  GetComponent&lt;Rigidbody&gt;().AddForce(movementVector * moveSpeed * Time.deltaTime);
  </code></pre>
  
  <p>But in this case, you are unable to rotate anymore then 180 degrees using WAD like the first example. Although it does solve the visual problem.</p>
  
  <p>How is it that I can allow my ball to rotate with the "A" and "D" keys, and then go in the direction the ball is facing with "W" while also visually rotating?</p>