According to the position of the cursor its shooting from the center to the right. But when I bring the cursor to the left it shoot in the straight center direction. Please help`
void update()
{
if (Input.GetKeyDown(KeyCode.Mouse0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
float dist;
if (m_ClickPlane.Raycast(ray, out dist))
{
Vector3 dir = (ray.GetPoint(dist) - gameObject.transform.position).normalized;
GameObject ball = (GameObject)Instantiate (prefab, gameObject.transform.localPosition, Quaternion.identity); ball.GetComponent<Rigidbody>().AddForce( dir*10, ForceMode.Impulse);
}
}
}