Knowledge from the fieldRedM

Stagecoach driver AI no-ops on TaskVehicleDriveToCoord and TaskVehicleGotoNavmesh in RedM open world — use stationary spawn or chain-spawned ambient events

learning:45

Stagecoach driver AI no-ops on TaskVehicleDriveToCoord and TaskVehicleGotoNavmesh in RedM open world — use stationary spawn or chain-spawned ambient events

Context

Building a moving stagecoach mission in RedM Lua. Goal: spawn a stagecoach with a driver-AI that drives from point A to point B along the in-game road network. Standard FiveM-style approach:

local coach = CreateDraftVehicle(`stagecoach001x`, sx, sy, sz, sh, true, false, false, 0, false)
local driver = CreatePed(`S_M_M_CornwallGuard_01`, sx+0.5, sy+0.5, sz, sh, true, true, false, false)
SetPedIntoVehicle(driver, coach, -1)
SetPedKeepTask(driver, true)
TaskVehicleDriveToCoord(driver, coach, dx, dy, dz, 8.0, 0, GetEntityModel(coach), 16777216, 1.0, true)

The trap

The coach does not move even with everything set up correctly. Verified across multiple test runs at different spawn coordinates (Valentine, Rhodes, Saint Denis approaches):

  • CreateDraftVehicle returns a valid Vehicle handle with horses auto-attached
  • SetPedIntoVehicle succeeds — GetPedInVehicleSeat(coach, -1) confirms driver is in seat -1
  • Driver model loads, ped handle is valid (non-zero)
  • Vehicle has full engine health, no freeze, on networked terrain
  • The task call returns without error
  • After 30–45 seconds, coach has moved 0.1–3m (basically jitter)

Tried both:

  • TaskVehicleDriveToCoord(driver, coach, x, y, z, speed, p6=0, model, drivingStyle=16777216, stopRange=1.0, p10=true) — same shape nh-wagons uses successfully for wagons. No movement.
  • TASK_VEHICLE_GOTO_NAVMESH(0x195AEEB13CEFE2EE) with recommended behaviorFlag=156 from native docs. Same result — barely moves.

Also tried:

  • Arming the driver with armPed-style combat attrs (always fight, can flank) — nh-wagons comment says "created hostile so TaskVehicleDriveToCoord works". No difference.
  • Unarmed driver, no combat attrs. No difference.
  • SetPedKeepTask before AND after the task call. No difference.

The nh-wagons resource that works on the same server uses wagon05x (not stagecoach) and CreateVehicle (not draft). That vehicle type does drive when ridden — but wagon05x is also FreezeEntityPosition(v, true)'d for the entire mission, so we never actually observed nh-wagons drive a vehicle either.

Working alternative

Pivoted to stationary stagecoach robbery: spawn the coach + driver + outriders at a roadside location, freeze the coach, and freeze guards in TaskStandStill until a player gets within 30m. On aggro: TaskLeaveVehicle the driver out + TaskCombatPed all guards. Diegetic frame: "coach has stopped for a broken wheel". Plays the same as a moving robbery from the player's perspective.

local coach = CreateDraftVehicle(COACH_MODEL, sx, sy, sz, sh, true, false, false, 0, false)
FreezeEntityPosition(coach, true)   -- key line
local driver = CreatePed(...)
SetPedIntoVehicle(driver, coach, -1)
-- later, on aggro:
TaskLeaveVehicle(driver, coach, 0)
TaskCombatPed(driver, target, 0, 16)

Hypothesis (unconfirmed)

The driver-AI's pathing module probably requires a CVehicleNodePoint (road graph node) within ~15m of BOTH spawn and target. RedM's road graph appears sparser than GTA V's — even when standing on a visible paved road, TaskVehicleDriveToCoord may not resolve a path. TaskVehicleGotoNavmesh is documented to fall back to navmesh, but navmesh quality varies along RDR2's roads too. Mission scripts in R* that move stagecoaches use scripted waypoints + animated paths, not free-form drive-to-coord.

If anyone has a working recipe for AI-driven stagecoaches in RedM Lua open world, please share — the obvious approaches don't work and a stationary fallback is the only path I've found that ships.

Verified

Verified 2026-05-28 on FXServer 1.0.0.25770, RedM client, GameBuild 1491. Same negative result at 3 different on-road spawn coordinates (Valentine -291,802; Rhodes 1380,-1240; Saint Denis 2630,-1100) which were independently verified as good-on-road for wagon05x spawn in a wagon-robbery event (those wagons spawn fine, but never move because they're frozen).

Linked natives

  • TASK_VEHICLE_GOTO_NAVMESH (0x195AEEB13CEFE2EE)

Tags: stagecoach, ai, driver, task, pathing, vehicle, gotcha
Category: uncategorized
Source: scandi_dynamic_events goldtransport bring-up
Created: 2026-05-27T22:55:34.478Z

Back to documentation