Documentation / Node reference / code nodes
code/RayClosestPoint
The point on a ray nearest a position, and the distance to it.
Geometry
Wire a code/CursorRay in and this measures how close something is to the line the pointer picks out through the scene. That distance, fed through a falloff, is how a cursor pushes or pulls a crowd of particles: near the ray they react, far from it they carry on.
A ray has a start, so anything behind it measures against that start rather than against the line running backwards. A cursor ray starts at the camera, which means what is behind the camera is not caught by it.
Wiring the previous ray as well changes what is measured, from a line to the fan the ray sweeps between the two. This matters more than it sounds: a pointer moving quickly covers real ground between one frame and the next, and measuring only against where it is right now lets things slip through the gaps. Feed both of a code/CursorRay's outputs in and a fast stroke acts on everything it crossed.
Parameters
| Name | Type | What it does |
|---|---|---|
| position | Vector3 | The position to measure from. Usually the point being processed, from a code/Globals. |
| maxSweepAngle | Float | How wide a sweep to believe, in degrees. A pointer that jumps across the screen at once (coming back to the window, or a warp) would otherwise drag everything along the whole arc it appears to have crossed. Past this angle the sweep is ignored and only the current ray is used. |
This page is generated from the engine, so it describes the release you can download. The same text is in the editor's Help panel next to the node itself.