Skip to content

Instantly share code, notes, and snippets.

@jorgenpt
Created April 18, 2012 23:36
Show Gist options
  • Save jorgenpt/2417387 to your computer and use it in GitHub Desktop.
Save jorgenpt/2417387 to your computer and use it in GitHub Desktop.
bool MouseLocationInWorld(out Vector3 location)
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast (ray, out hit, 100))
{
location = hit.point;
return true;
}
location = Vector3.zero;
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment