Garry's Mod Wiki


  Vector, Vector, number util.IntersectRayWithOBB( Vector rayStart, Vector rayDelta, Vector boxOrigin, Angle boxAngles, Vector boxMins, Vector boxMaxs )


Performs a "ray" box intersection and returns position, normal and the fraction.


1 Vector rayStart
Origin/start position of the ray.
2 Vector rayDelta
The ray vector itself. This can be thought of as: the ray end point relative to the start point.

Note that in this implementation, the ray is not infinite - it's only a segment.

3 Vector boxOrigin
The center of the box.
4 Angle boxAngles
The angles of the box.
5 Vector boxMins
The min position of the box.
6 Vector boxMaxs
The max position of the box.


1 Vector
Hit position, nil if not hit.
2 Vector
Normal/direction vector, nil if not hit.
3 number
Fraction of trace used, nil if not hit.