---
name: "calculatePath"
type: command
status: ok
groups: ["Object Manipulation"]
arma3_since: "1.94"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/calculatePath
revid: 376951
updated: 2026-01-01T04:02:40Z
---

# calculatePath

*Command · Object Manipulation · Arma 3 v1.94*

## Description

Spawns an agent that will execute an AI path calculation and fire the `"PathCalculated"` [event handler](../topics/Event_Handlers.md#pathcalculated).
The vehicle type to simulate could be one of the following presets:
- `"man"`: C_man_1
- `"car"`: C_Offroad_01_F
- `"tank"`: B_MBT_01_cannon_F
- `"wheeled_APC"`: B_APC_Tracked_01_rcws_F
- `"boat"`: C_Rubberboat
- `"plane"`: B_Plane_CAS_01_dynamicLoadout_F
- `"helicopter"`: B_Heli_Light_01_F

If the given vehicle type is not one of the above presets, the exact given type is used.

> [!IMPORTANT]
> In order to guarantee that the event handler is added to the result of this command before the path is calculated, use [isNil](../commands/isNil.md) to run the code in an [Unscheduled Environment](../topics/Scheduler.md#unscheduled-environment):
>
> ```sqf
> isNil { calculatePath ["man", "safe", _startPos, _endPos] addEventHandler ["PathCalculated", { hint str _this }] };
> ```

> [!NOTE]
> If an exact path is desired, it is recommended to avoid this command and simply use the [PathCalculated](../topics/Event_Handlers.md#pathcalculated) event handler.
> Paths to long distances are typically calculated in segments. This command only gives the first calculated segment.

## Syntax

```sqf
calculatePath [type, behaviour, from, to]
```

**Parameters:**

- `type`: [String](../topics/String.md) - vehicle type to simulate (see description)
- `behaviour`: [String](../topics/String.md) - AI [behaviour](../commands/behaviour.md), one of "CARELESS", "SAFE", "AWARE", "COMBAT" or "STEALTH"
- `from`: [Array](../topics/Array.md) - start position in format [x,y,z]
- `to`: [Array](../topics/Array.md) - end position in format [x,y,z]

**Returns:** [Object](../topics/Object.md) - the agent to [add](../commands/addEventHandler.md) the [`"PathCalculated"` Event Handler](../topics/Event_Handlers.md#pathcalculated) to.

## Examples

### Example 1

```sqf
calculatePath ["car", "safe", [2150.67,5778.19,0], [2184.11,5802.28,0]];
```

### Example 2

Draws the path from South West to North East of Agia Marina:

```sqf
(calculatePath ["man", "safe", [2832.9,5927.79,0], [3107.46,6036.61,0]]) addEventHandler ["PathCalculated", {
    {
        private _marker = createMarker ["marker" + str _forEachIndex, _x];
        _marker setMarkerType "mil_dot";
        _marker setMarkerText str _forEachIndex;
    } forEach (_this select 1);
}];
```

### Example 3

Alternative usage of [calculatePath](../commands/calculatePath.md) functionality that is free of the double execution bug (and calculatePath command):

```sqf
private _agent = createAgent [typeOf player, position player, [], 0, "NONE"];
_agent addEventHandler ["PathCalculated",
{ 
    { 
        private _marker = createMarker ["marker" + str _forEachIndex, _x];
        _marker setMarkerType "mil_dot";
        _marker setMarkerText str _forEachIndex;
    } 
    forEach (_this select 1);
}];
_agent setDestination [player getRelPos [500, 0], "LEADER PLANNED", true];
```

### Example 4

Same as above but for a vehicle:

```sqf
private _agent = createAgent [typeOf player, position player, [], 0, "NONE"];
private _car = "B_Quadbike_01_F" createVehicle position player;
_agent moveInDriver _car;
_agent addEventHandler ["PathCalculated",
{ 
    { 
        private _marker = createMarker ["marker" + str _forEachIndex, _x];
        _marker setMarkerType "mil_dot";
        _marker setMarkerText str _forEachIndex;
    } 
    forEach (_this select 1);
}];
_agent setDestination [player getRelPos [500, 0], "LEADER PLANNED", true];
```

## Problems

For some unknown reason, the "PathCalculated" Event Handler is fired twice, first with the calculated path and second with an array consisting of 2 elements, which are identical and are equal to the end point.
See **[Example 3 & 4](../commands/calculatePath.md#examples)** for a workaround.

## See also

[setDriveOnPath](../commands/setDriveOnPath.md) · [setDestination](../commands/setDestination.md)

## Community notes

**Tankbuster** — 2019-06-06

When using this command to get the predicted path of vehicles driving and having them stay on roads (not go cross country) is important,
the best vehicle to use is "wheeled_APC" and careless [behaviour](../commands/behaviour.md).

<sub>Source: [BI Community Wiki — calculatePath](https://community.bistudio.com/wiki/calculatePath) (revision 376951).</sub>
