setPedGoTo
Send an NPC straight toward a nearby coordinate. GTA handles the walk or run, slows the NPC down, and stops it inside the arrival radius.
Complete example
-- client.lua-- Sweet runs directly to a nearby point and stops there.local sweet = createPed(270, 2495.2, -1687.4, 13.5)local destination = Vector3(2520.0, -1672.0, 13.8)
if sweet then assert(setPedGoTo(sweet, destination, "run", 0.75, 3.0))endSyntax
bool setPedGoTo(ped thePed, Vector3 target [, string movement = "walk", float radius = 0.5, float slowdownRadius = 2.0, int timeout = -2])GTA task mapping
05D3 CTaskComplexGoToPointAndStandStillCTaskComplexGoToPointAndStandStillTimedSCM equivalent: TASK_GO_STRAIGHT_TO_COORD
San Andreas Online selects the untimed task for timeout -2. Every other value uses the timed variant, with -1 normalized to GTA's 20-second SCM default.
Arguments
thePedpedLiving streamed ped simulated by this client.
targetVector3Finite destination.
movementstringoptional · default walkwalk, run, or sprint.
radiusfloatoptional · default 0.5Positive arrival radius.
slowdownRadiusfloatoptional · default 2.0Slowdown radius not smaller than radius.
timeoutintoptional · default -2-2 for untimed, -1 for SCM-compatible 20 seconds, or a non-negative millisecond timeout.
Returns
true when the native task was installed; false when ownership, streaming, liveness, target, movement, radius, or timeout checks fail.
Ownership and lifecycle
Low-level ped task calls require the client that simulates the living, streamed ped. Driving tasks also require control of the streamed vehicle. They do not create lifecycle handles; the optional native-task-runtime adds server-owned route epochs and reconstruction for drive_to routes. Gang-tag ownership is resource-exclusive, survives object streaming and recreation, and is released automatically when the owner stops.
- This is GTA's straight-to-coordinate task. For a route through GTA's pedestrian path network and around buildings, use setPedNavigateTo.
OOP aliases
ped:setGoTo(target, movement, radius, slowdownRadius, timeout)
Where this comes from
Continue exploring
← Back to the SA:O Lua API · How Native ped tasks and gang tags works →