Garry's Mod Wiki

util.IsRayIntersectingRay

  boolean, number, number util.IsRayIntersectingRay( Vector ray1Start, Vector ray1End, Vector ray2Start, Vector ray2End )

Recently Added

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

Description

Performs a ray-ray intersection and returns whether there was an intersection or not.

Arguments

1 Vector ray1Start
Start position of the first ray.
2 Vector ray1End
End position of the first ray.
3 Vector ray2Start
Start position of the second ray.
4 Vector ray2End
End position of the second ray.

Returns

1 boolean
true if there is an intersection, false otherwise.
2 number
Distance from start of ray 1 to the intersection, if there was one.
3 number
Distance from start of ray 2 to the intersection, if there was one.