API Reference GE Extensions flowgraph nodes vehicle ai AI Directly To - **Node Name:** `AI Directly To`
Node Name: AI Directly To
Category: custom (duration + once behavior)
File: extensions/flowgraph/nodes/vehicle/ai/directlyTo.lua
Drives a vehicle directly toward a target position using scripted AI path following. Unlike waypoint-based navigation, this generates a straight-line path divided into steps. Outputs flow once the vehicle arrives within minDistance.
Pin Type Default Description flowflow - Inflow for the node resetflow (impulse) - Resets the node state vehIdnumber - Vehicle ID (uses player vehicle if empty) targetvec3 - World position to drive to targetVelocitynumber - Target speed while driving (m/s)
Pin Type Description flowflow Outflow - active once the vehicle has arrived
Method Description init()Sets up state flags and data defaults reset()Clears started/complete flags and stops the AI getVeh()Resolves vehicle by ID or player vehicle setupAI()Generates a straight-line path and starts ai.startFollowing() endAI()Calls ai:scriptStop() with optional handbrake/wheel straightening work()Monitors distance to target, transitions to complete
Field Default Description minDistance1.5Arrival distance threshold (meters) handBrakeWhenFinishedfalseApply handbrake on arrival straightenWheelsWhenFinishedfalseStraighten wheels on arrival maxStepDistance5Maximum distance between path waypoints
Computes the direction vector from vehicle position to target.
Divides the path into steps of at most maxStepDistance.
Creates steps + 3 extra path points beyond the target (overshoot buffer).
Each point includes {x, y, z, t} where t = distance / speed.
Sends path via ai.startFollowing(path, nil, 0, "neverReset").
On first flow, calls setupAI() to generate and send the path.
Each subsequent frame, checks squared distance from vehicle to target.
When distance < minDistance², calls endAI() and sets complete = true.
Once complete, outputs flow on the flow output pin.
The reset impulse pin restarts the entire process.
-- Drive vehicle to a specific world position:
-- vehId = vehicleId
-- target = {100, 200, 30}
-- targetVelocity = 10 (10 m/s ≈ 36 km/h)
-- Wait for arrival then trigger next action:
-- Connect flow output → next node in sequence
-- Reset to drive to a new position:
-- Send impulse to 'reset', then update 'target'
ai.startFollowing() - scripted path following
ai:scriptStop() - stops scripted AI driving