Answers for "unity mouse position to world"

C#
7

unity how to convert mouse screen position to world position

Camera.main.ScreenToWorldPoint(Input.mousePosition)
Posted by: Guest on October-05-2020
22

unity mouse position to world

Vector3 worldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Posted by: Guest on July-16-2020
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