Skip to content

Instantly share code, notes, and snippets.

@sirtawast
Last active June 1, 2016 07:11
Show Gist options
  • Save sirtawast/2ec8fe918ba78f6cf0f5 to your computer and use it in GitHub Desktop.
Save sirtawast/2ec8fe918ba78f6cf0f5 to your computer and use it in GitHub Desktop.
Cursor point raycasting in Unity3D
// Invert mouse y-axis and reduce taskbar height
Vector2 mousePos = Event.current.mousePosition;
mousePos.y = Screen.height - 35 - mousePos.y;
// Raycast
Ray ray = Camera.current.ScreenPointToRay(mousePos);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment