Ray Detector
Detect objects or players using raycasting.
Introduction
Ray Detector fires a straight laser and senses whatever it touches, like a tripwire beam in a heist map. A word of caution: lasers cost performance, so keep the count sensible, around one hundred per game at most. The Ray Detector component panel in the Uni editor Image The Ray Detector component panel in the Object editor. caption
How to Access
Select an object, open the Properties Panel, then press the Add Component button at the bottom and pick Ray Detector. The component stacks onto the object as a new accordion of properties. How to Access - Add Component in the Properties Panel
Another Way to Access
Shortcut: open the Asset Panel, go to the Device tab, Basic category, and click the Ray Detector block. The editor spawns a cube with Ray Detector already attached, ready to adjust. How to Access - the Ray Detector block in Asset Panel > Device > Basic
Properties
Distance Float The maximum reach of the beam. Color The color of the laser. Width Int The thickness of the beam line. Flashing Speed How fast the beam visually blinks. Cast Interval The pause between detection scans. This does not affect FPS, only how late an event can fire after a hit. Visible Bool Whether the laser is actually visible in the world or works invisibly. X-Ray Lets the beam pass through objects instead of stopping at them. Offset Vector3 Shifts where the beam starts relative to the object’s center. Rotation The direction the beam is fired in. Is Hit The master switch. When off, the laser is pure decoration and never fires events. Property Type Description Every property on the Ray Detector component.
Events
When Hit Target Change Fires only when the object being hit changes, and the object it reports is the outermost group of whatever was struck. Going from hitting something to hitting nothing does not fire this event. Object: the outermost object detected Event Description Parameter Every event on the Ray Detector component. Each event links to its full guide, where its parameters and example live.
Commands
Ray Detector has no commands.
Example
A player dies when touching a laser. Ray Detector - Simple video