Arma 3 Scripting

deleteWaypoint

  • Global argument
  • Global effect
  • Arma 3 v0.50
  • First in Operation Flashpoint: Elite v1.00

Command · Markdown · JSON · original wiki page

Description

Removes the specified waypoint.

Note

  • When a waypoint is deleted, all other group waypoints are immediately re-indexed. See #Example 2 for a deletion of all group's waypoints.
  • Deleting a group's current waypoint will not stop the group on its tracks.

Syntax

deleteWaypoint [group, index]

Parameters:

Returns: Nothing

Examples

Example 1

deleteWaypoint [_grp, 2];

Example 2

Because waypoints get immediately re-indexed when one gets deleted, delete them from last to first:

private _group = group _unit;
for "_i" from (count waypoints _group - 1) to 0 step -1 do
{
    deleteWaypoint [_group, _i];
};

or always delete the first one (if you want to delete them all)

private _group = group _unit;
for "_i" from 0 to (count waypoints _group - 1) do
{
    deleteWaypoint [_group, 0];
};

or use forEachReversed:

{ deleteWaypoint _x } forEachReversed waypoints _group; // Arma 3 v2.14+ only

See also

waypoints · setCurrentWaypoint · setWaypointPosition · setWaypointScript · setWaypointStatements · setWaypointType · addWaypoint

Community notes

Saintolaf

In order to change the behavior of a unit currently following some waypoints, it is not enough to use deleteWaypoint. To achieve the wanted effect, you should rather use setWPPos to the unit's current position (thereby stopping the unit), and (after a small delay) use deleteWaypoint to remove the next waypoints.

VictorFarbau

Another (more foolproof) method to avoid the problem of non-deleteable waypoints is to introduce another group (createGroup) and join all units of the present group. A new group will start without any preset waypoints so you can start setting new WPs all over again. Old group is "_combatGroup", new group is "_combatGroup2"

_combatGroup2 = createGroup east;
{ [_x] joinSilent _combatGroup2 } forEach (units _combatGroup);
_combatGroup2 addWaypoint [getPos player, 25];