---
name: "setDir"
type: command
status: ok
groups: ["Object Manipulation"]
arma3_since: "0.50"
locality: {"argument": "local", "effect": "global", "server_exec": false}
source: https://community.bistudio.com/wiki/setDir
revid: 373376
updated: 2025-05-04T21:12:49Z
---

# setDir

*Command · Object Manipulation · Arma 3 v0.50 · introduced in Operation Flashpoint v1.00*

Locality: arguments **local** · effect **global**

## Description

Sets object heading. Angles are measured in degrees clockwise from north; the regular range goes from 0 to 360 (0° = N, 90° = E, 180° = S, 270° = W). Negative angles represent counter-clockwise angles.

> [!IMPORTANT]
> This command resets the object's [velocity](../commands/velocity.md) and [vectorUp](../commands/vectorUp.md)!

> [!NOTE]
> In *some* earlier titles (Operation Flashpoint?), this command was Local Effect.

## Syntax

```sqf
object setDir heading
```

**Parameters:**

- `object`: [Object](../topics/Object.md)
- `heading`: [Number](../topics/Number.md)

**Returns:** [Nothing](../topics/Nothing.md)

## Examples

### Example 1

```sqf
myUnit setDir 45; // will set myUnit to face North-East
```

### Example 2

```sqf
myUnit setDir -675; // will also set myUnit to face North-East (= 45-360-360)
```

### Example 3

```sqf
MyUnit setDir 30;
MyUnit setFormDir 30; // needed for AI to keep the given direction
```

### Example 4

```sqf
// provided _myMine is local
_myMine setDir 45;
_myMine setPosWorld getPosWorld _myMine;

// or
[_myMine, 45] remoteExec ["setDir"];
```

### Example 5

```sqf
// sets the direction of an object relative to a parent object's direction
_child setDir (_parentDir + (_childDir - _parentDir));
```

## Multiplayer

See the [#Notes](../commands/setDir.md#notes) below

## Problems

- The effect is Local Effect when using [setDir](../commands/setDir.md) on a mine. Use a position modification to broadcast [setDir](../commands/setDir.md)'s change (see [#Example 4](../commands/setDir.md#example-4))
- setting direction *after* position may lead to weird behaviours - see [#Notes](../commands/setDir.md#notes)

## See also

[getDir](../commands/getDir.md) · [direction](../commands/direction.md) · [setFormDir](../commands/setFormDir.md) · [setVectorDir](../commands/setVectorDir.md) · [setVectorDirAndUp](../commands/setVectorDirAndUp.md)

## Community notes

**Manny** — 2007-05-09

Though effects of this command remain local, you can do a [setPos*](../commands/setPosASL.md) afterwards to synchronize the direction on all machines in MP.

```sqf
myObj setDir 90;
myObj setPosASL getPosASL myObj;
```

---

**.kju** — 2001-04-05

In Arma 2: Operation Arrowhead 1.59 the comment of Manny still holds true for [createVehicle](../commands/createVehicle.md)'d empty vehicles by the server.
For the player object a local [setDir](../commands/setDir.md) alone is enough.

---

**Killzone_Kid** — 2013-11-25

In Arma 3, [setDir](../commands/setDir.md) affects [vectorUp](../commands/vectorUp.md), [vectorDir](../commands/vectorDir.md) and [velocity](../commands/velocity.md) of the object it applied to. While this is not noticeable with stationary objects, a moving objects will have its orientation and velocity reset. So if you are planning on using [setDir](../commands/setDir.md) on a moving object, make sure you read the velocity value before and restore it after if you want the object to continue to move.

```sqf
_vel = velocity _object;
_object setDir 45;
_object setVelocity _vel;
```

With orientation it is a bit more complicated. [setDir](../commands/setDir.md) resets [vectorUp](../commands/vectorUp.md) to [0,0,1] and changes [vectorDir](../commands/vectorDir.md) accordingly to accommodate set direction. If your object's [vectorUp](../commands/vectorUp.md) is not [0,0,1] and you want to keep it this way, then you have to use [setVectorDirAndUp](../commands/setVectorDirAndUp.md) to change object's direction not [setDir](../commands/setDir.md). This is also the reason why it is better to use [setVectorDirAndUp](../commands/setVectorDirAndUp.md) instead of [setDir](../commands/setDir.md) on attached objects for a better control of object's orientation.

---

**Killzone_Kid** — 2013-11-27

Make sure you [setDir](../commands/setDir.md) BEFORE you set position. **Setting direction after set position could lead to unpredictable behaviour**. For example main part of the hospital building in Arma 3 can lose collision detection near both side entrances. AI will also get confused and will stop detecting obstacles if [setDir](../commands/setDir.md) is called after [setPos](../commands/setPos.md).

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