Created
April 18, 2012 23:36
-
-
Save jorgenpt/2417387 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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