title: How to apply force to an object in a particular direction in Unity
body: <p>I'm using unity to develop my game. I've made a custom swipe gesture by calculating the startPosition and the end Position of the touch. I got the vector direction by subtracting the two positions and debugged it successfully. </p>
  
  <p>But when it comes to applying force to my game object I'm not getting any success after trying a lot.</p>
  
  <p>here's what I'm doing:</p>
  
  <pre><code>swipeDirection = new Vector3(endPos.x - startPos.x,0f, endPos.z - startPos.z);
  
  swipeDirection.Normalize();
  
  Debug.Log("The direction is "+ swipeDirection);
  
  ball.rigidbody.AddForce(swipeDirection * 5);
  </code></pre>
  
  <p>where ball is just a GameObject. Whenever I run it on my iPhone, the game just gets stuck giving a EXC_BAD_ACCESS code after the first swipe.</p>