Garry's Mod Wiki

util.IntersectRayWithPlane

  Vector, number util.IntersectRayWithPlane( Vector rayOrigin, Vector rayDirection, Vector planePosition, Vector planeNormal )

Description

Performs a ray-plane intersection and returns the hit position or nil.

Arguments

1 Vector rayOrigin
Origin/start position of the ray.
2 Vector rayDirection
The direction of the ray.
3 Vector planePosition
Any position of the plane.
4 Vector planeNormal
The normal vector of the plane.

Returns

1 Vector
The position of intersection, nil if not hit.
2 number
The distance from start position to the hit point, if there was a hit.

This was recently added in version (2026.07.17). It might only be available on the Dev Branch right now.