_EagleOwle_

Cursor position to world

Jun 24th, 2021
437
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     }
RAW Paste Data