Description
The GetMouseDistance
method calculates the distance from the mouse cursor to a specified plane in 3D space. This is useful for determining how far the mouse is from a given point on a plane, which can be used in various interactive applications such as 3D modeling or game development.
Usage
To use the GetMouseDistance
method, provide the position of a point on the plane and the normal vector of the plane. The method will return the distance from the mouse cursor to the plane along the plane's normal.
Parameters:
position
(Vector3
): A point on the plane in 3D space.
planeNormal
(Vector3
): The normal vector of the plane, which defines its orientation.
Returns: System.Single
- The distance from the mouse cursor to the specified plane.
Example
// Example usage of GetMouseDistance
Vector3 planePosition = new Vector3(0, 0, 0); // A point on the plane
Vector3 planeNormal = new Vector3(0, 1, 0); // The normal of the plane
float distance = Gizmo.GetMouseDistance(planePosition, planeNormal);
// Use the distance for further calculations or logic
if (distance < 10.0f)
{
// Perform some action if the mouse is within 10 units of the plane
}