API Reference GE Extensions flowgraph nodes vehicle special Wheel Distance - **Node Name:** `Wheel Distance`
Node Name: Wheel Distance
Category: repeat_p_duration
File: extensions/flowgraph/nodes/vehicle/special/wheelDistance.lua
Calculates the distance from the closest wheel center(s) of a vehicle to a given world-space point. Useful for precise start/finish line detection in races.
Pin Type Description vehIdnumber Vehicle ID. Falls back to player vehicle if empty. positionvec3 World-space target position to measure distance to.
Pin Type Description distancenumber Signed distance from the closest wheel pair midpoint to the target, projected along the vehicle's forward axis.
Method Description init()Sets data.debug = false and data.onlyUseFrontWheels = true. calculateDistanceFromStart(vehicle, target)Core calculation - iterates all wheels, finds the two closest, and computes signed distance. work()Resolves the vehicle, reads the position pin, and calls calculateDistanceFromStart.
Function Description getTwoSmallestValues(values)Finds the two wheels with the smallest distance to the target. Returns a pair (or duplicates the single closest for odd wheel counts).
Iterates over all vehicle wheels using veh:getWheelCount() and veh:getWheelAxisNodes().
Optionally filters to front wheels only (dot product of wheel-to-center vector with direction vector > 0).
For each qualifying wheel, projects the wheel-to-target vector onto the vehicle's forward direction to get a scalar distance.
Finds the two closest wheels and averages their positions.
Computes the final signed distance from this midpoint to the target, projected along the forward axis.
In debug mode, draws lines, spheres, and text labels using debugDrawer.
-- Flowgraph:
-- [Vehicle Provider] → vehId → [Wheel Distance] ← position ← [Start Line Pos]
-- ↓
-- distance → [Compare: < 0.5] → [Race Started!]
-- The signed distance is negative when the vehicle has passed the target point.
-- This allows precise start/finish line crossing detection.
veh:getWheelCount() / veh:getWheelAxisNodes() - wheel node access
veh:getNodePosition() - beam node world positions
veh:getSpawnWorldOOBB() - oriented bounding box for center calculation
debugDrawer - optional visual debug output