Answers for "unity mouse world position"

C#
1

unity mouse world position

//check for Left mouse Key 
if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;

            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100))
            {
				//hit.point is the position, where the Raycast from the camera
              	//position towards the ground hit the first collider
                Vector3 positionInWorld = hit.point; 
              
              	//Do something with positionInWorld here...
               
            }
        }
Posted by: Guest on May-31-2021

C# Answers by Framework

Browse Popular Code Answers by Language