API ReferenceGE Extensionsflowgraphnodesscene
Raycast (Flowgraph Node)
- **Node Name:** `Raycast`
Overview
- Node Name:
Raycast - Category:
repeat_instant - File:
extensions/flowgraph/nodes/scene/raycast.lua
Casts a ray and hits the first static collision object (TSStatics, Terrain, etc.).
Pin Schema
Input Pins
| Pin | Type | Description |
|---|---|---|
pos | vec3 | Start position of the raycast |
dir | vec3 | Direction of the raycast |
dist | number | (Hidden) Maximum distance (default 1000) |
Output Pins
| Pin | Type | Description |
|---|---|---|
hit | flow | Outflow if the ray hit something |
miss | flow | (Hidden) Outflow if nothing was hit within dist |
pos | vec3 | Hit position |
dist | number | Distance from origin to hit point |
Internals
| Field | Purpose |
|---|---|
self.data.debug | When true, draws debug spheres and lines |
Behavior
work()- Each frame:- Calls
castRayStatic(pos, dir, dist)to find the nearest static hit. - Computes hit position as
pos + normalized(dir) * hitDist. - Sets
hitflow ifhitDist < dist, otherwise setsmiss. - Optional debug drawing shows start (red), hit (green), and connecting line (blue).
- Calls
How It Works
- The node takes a position and direction vector each frame.
- If no explicit distance is provided, uses the length of the direction vector.
castRayStatic()returns the distance to the nearest static collision surface.- The hit position is calculated and output along with the distance.
Example Usage
-- Check ground height below a point:
-- pos = {100, 200, 500}
-- dir = {0, 0, -1}
-- dist = 1000
-- Output pos.z gives the terrain height at (100, 200)Key Dependencies
castRayStatic(pos, dir, dist)- engine function for static collision raycasting
Additional Methods
C:init()
Initializes the node, setting up pins and default properties.
See Also
- Collection Marker (Flowgraph Node) - Related reference
- Custom Lua Command (Flowgraph Node) - Related reference
- Get Object Field (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide