util.IntersectRayWithOBB
Vector, Vector, number util.IntersectRayWithOBB( Vector rayStart, Vector rayDelta, Vector boxOrigin, Angle boxAngles, Vector boxMins, Vector boxMaxs )
Description
Performs a Ray-OBB (Orientated Bounding Box) intersection and returns position, normal and the fraction if there was an intersection.
Arguments
2 Vector rayDelta
The ray vector itself, the ray end point relative to the start point. Can be implemented as
direction * distance
Note that in this implementation, the ray is not infinite - it's only a segment.
Returns
Example
Simple example showing example usage of the function with visualization. Enter developer 1
into the in-game console, and look at any entity. Will display a red box if there is no intersection, a green one if there is an intersection.
Please note that while the example uses an entity to generate a box, it is not necessary. The whole point is to perform intersection checks against non physical objects, for example an in-world user interface screen, or testing if a player (or an NPC) is looking at a certain part of a map.