Advertisement
_EagleOwle_

Cursor position to world

Jun 24th, 2021
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.32 KB | None | 0 0
  1. public Vector3 GetCursorPosition()
  2.     {
  3.         Vector3 mouse = Input.mousePosition;
  4.         Ray castPoint = Camera.main.ScreenPointToRay(mouse);
  5.         RaycastHit hit;
  6.         if (Physics.Raycast(castPoint, out hit, Mathf.Infinity))
  7.         {
  8.             return hit.point;
  9.         }
  10.  
  11.         return Vector3.zero;
  12.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement