---
name: "getCameraViewDirection"
type: command
status: ok
groups: ["Object Manipulation"]
arma3_since: "1.58"
locality: {"argument": "global", "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/getCameraViewDirection
revid: 349460
updated: 2023-11-08T16:48:37Z
---

# getCameraViewDirection

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

Locality: arguments **global**

## Description

Returns the direction unit is looking in render time scope. While for AI the origin for the view direction vector can be taken from `eyePos unit`, for human player the origin should be taken from player camera position `positionCameraToWorld [0,0,0]`

## Syntax

```sqf
getCameraViewDirection unit
```

**Parameters:**

- `unit`: [Object](../topics/Object.md)

**Returns:** [Array](../topics/Array.md) - 3D Vector

## Examples

### Example 1

Draw AI eye direction (green), weapon direction (red) and camera direction (blue) in 3D:

```sqf
Bob = createGroup east createUnit ["O_Soldier_F", [0,0,0], [], 0, "NONE"];
Bob setVehiclePosition [player modelToWorld [0,100,0], [], 0, "NONE"];
onEachFrame {
    _beg = ASLToAGL eyePos Bob;
    _endE = (_beg vectorAdd (eyeDirection Bob vectorMultiply 100));
    drawLine3D [_beg, _endE, [0,1,0,1]];
    _endW = (_beg vectorAdd (Bob weaponDirection currentWeapon Bob vectorMultiply 100));
    drawLine3D [_beg, _endW, [1,0,0,1]];
    _endV = (_beg vectorAdd (getCameraViewDirection Bob vectorMultiply 100));
    drawLine3D [_beg, _endV, [0,0,1,1]];
};
```

## See also

[positionCameraToWorld](../commands/positionCameraToWorld.md) · [weaponDirection](../commands/weaponDirection.md) · [eyeDirection](../commands/eyeDirection.md) · [vectorDir](../commands/vectorDir.md) · [vectorDirVisual](../commands/vectorDirVisual.md)

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