Created
March 15, 2014 19:52
-
-
Save britg/9572946 to your computer and use it in GitHub Desktop.
Screen to world point with oblique camera
This file contains 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
Vector2 mousePos = Input.mousePosition; | |
if (lastMousePos.Equals(mousePos)) { | |
return; | |
} | |
lastMousePos = mousePos; | |
Ray ray = Camera.main.ScreenPointToRay(mousePos); | |
float dist; | |
Plane plane = new Plane(Vector3.up, Vector3.right, Vector3.down); | |
plane.Raycast(ray, out dist); | |
Vector3 worldPoint = Camera.main.ScreenToWorldPoint(new Vector3(mousePos.x, mousePos.y, dist)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment