title: Mouse based aiming Unity3d
body: <p>I am making cannonball shooter game. here's a short code where I am calculating the aiming direction.</p>
  
  <pre><code>            Vector3 mousePos = Input.mousePosition;
              mousePos.z = thisTransform.position.z - camTransform.position.z;
              mousePos = mainCamera.ScreenToWorldPoint (mousePos);
  
              Vector3 force = mousePos - thisTransform.position;
              force.z = force.magnitude;
  </code></pre>
  
  <p>This works when both ball and at angle (0,0,0). But when the angle changes, I am not able to shoot at right direction.</p>
  
  <p>Suppose both ball and camera are looking at 45 degrees on right side, the same code doesn't work.</p>
  
  <p>The current code assumes both are at angle (0,0,0). So in the above mentioned case, the throwing direction is always wrong.</p>
  
  <p>I want to throw the ball in whatever direction it is. But assume it as 0 angle and throw accordingly.</p>