Please also check the video below. I'm trying to make the player, the origin of the raycast. When I draw the ray, the origin is the soldier, so it appears to be correct. But the 0 point is the lower left corner of the screen instead of the player itself. How can I make the player the zero point please ? Code (CSharp): void Update () { aimFrom.y = player.transform.position.y; aimFrom.x = player.transform.position.x; direction = (Input.mousePosition - player.transform.position).normalized ; Physics2D.Raycast (aimFrom,direction); Debug.DrawRay(aimFrom,direction);
Input.mousePosition is in screen space, whereas player.transform.position is in world space. You need to convert one of the two, usually Input.mousePosition. You can use Camera.ScreenToWorldPoint() to do that.