Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

Get Mouse World Position

public Vector3 worldPosition;

void Update()
{
    Plane plane = new Plane(Vector3.up, 0);

    float distance;
    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    if (plane.Raycast(ray, out distance))
    {
        worldPosition = ray.GetPoint(distance);
    }
}Copy
Source by gamedevbeginner.com #
 
PREVIOUS NEXT
Tagged: #Get #Mouse #World #Position
ADD COMMENT
Topic
Name
1+7 =