Get world point where spotlight hits

Is there a way to get the point in the world where a spotlight (LIGHT_SPOT) hits an object? And if not hitting an object, I would like to have the point where the spotlight ends when I’ve defined “SetRange(x)” for the light.

If so, it would also be good if I could get the actual object being hit.

You’d probably want to use an octree raycast, as happens in several samples:

Instead of the cameraRay you would have a ray starting at the position of the spotlight with a maxDistance equal to the light’s range.
Once you have a RayQueryResult you’ve got a Node which you can check for tags or derived components as well as the position where the ray hit.

Thanks! Worked like a charm!

1 Like