Skip to content

Instantly share code, notes, and snippets.

@britg
Created March 15, 2014 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save britg/9572946 to your computer and use it in GitHub Desktop.
Save britg/9572946 to your computer and use it in GitHub Desktop.
Screen to world point with oblique camera
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