---
name: "selectionVectorDirAndUp"
type: command
status: ok
groups: ["Object Manipulation"]
arma3_since: "2.06"
locality: {"argument": "global", "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/selectionVectorDirAndUp
revid: 377722
updated: 2026-01-02T09:17:58Z
---

# selectionVectorDirAndUp

*Command · Object Manipulation · Arma 3 v2.06*

Locality: arguments **global**

## Description

Searches for selection in the object model's LOD level, and returns the Direction and Up vectors in model space.

## Syntax

```sqf
object selectionVectorDirAndUp [selectionName, LOD]
```

**Parameters:**

- `object`: [Object](../topics/Object.md)
- `selectionName`: [String](../topics/String.md) - selection name (see [selectionNames](../commands/selectionNames.md))
- `LOD`: [String](../topics/String.md) or [Number](../topics/Number.md) - the LOD that contains the selection:
  - [String](../topics/String.md) - can be one of:
    - "Memory"
    - "Geometry"
    - "FireGeometry"
    - "LandContact"
    - "HitPoints"
    - "ViewGeometry"
  - [Number](../topics/Number.md) - command searches for a LOD with the similar resolution (see [allLODs](../commands/allLODs.md)).

**Returns:** [Array](../topics/Array.md) with [[vectorDir](../commands/vectorDir.md), [vectorUp](../commands/vectorUp.md)] - vectors are in model space
- vectorDir: [Vector3D](../topics/Vector3D.md)
- vectorUp: [Vector3D](../topics/Vector3D.md)

## Examples

### Example 1

```sqf
vehicle player selectionVectorDirAndUp ["drivewheel_axis", "FireGeometry"] params ["_axisVectorDir", "_axisVectorUp"];
```

### Example 2

Get the player's barrel end (`_p1` being muzzle end's ASL position):

```sqf
onEachFrame {
    private _weapon = currentWeapon player;
    if (_weapon == "") exitWith {};

    // update weapon info upon weapon switch
    if (_weapon != player getVariable ["last_weapon", "?"]) then
    {
        private _cfg = configFile >> "CfgWeapons" >> _weapon;
        private _model = getText(_cfg >> "model");
        private _simpleObject = createSimpleObject [_model, [0,0,0], true];
        private _offset = _simpleObject selectionPosition [getText (_cfg >> "muzzlePos"), "memory"];
        _offset = _offset apply { [_x] };
        deleteVehicle _simpleObject;
        player setVariable ["offset", _offset];
        player setVariable ["last_weapon", _weapon];
        player setVariable ["proxy",
            [
                "proxy:\a3\characters_f\proxies\pistol.001",
                "proxy:\a3\characters_f\proxies\weapon.001",
                "proxy:\a3\characters_f\proxies\launcher.001",
                "proxy:\a3\characters_f\proxies\binoculars.001"
            ] select (([1, 4, 4096] find getNumber (_cfg >> "type")) + 1)
        ];
    };

    _offset = player getVariable ["offset", []];
    private _proxy = player getVariable ["proxy", ""];
    // using LOD resolution 1 (and lod index 0) - this is not always reliable
    // you should manually check allLODs and find the most suitable LOD (smallest res LOD usually has the best accuracy, but it might be slow too)
    player selectionVectorDirAndUp [_proxy, 1] params ["_vy", "_vz"];
    private _pos = selectionPosition [player, _proxy, 0];
    private _vx = _vy vectorCrossProduct _vz;

    private _mat = matrixTranspose [_vx, _vy, _vz];
    _pos = _pos vectorAdd flatten (_mat matrixMultiply _offset);

    private _p1 = player modelToWorldVisualWorld _pos;
    private _p2 = _p1 vectorAdd (player vectorModelToWorldVisual (_vx vectorMultiply -1000));
    drawLine3D [ASLToAGL _p1, ASLToAGL _p2, [1,0,0,1]];
};
```

## See also

[selectionPosition](../commands/selectionPosition.md) · [selectionNames](../commands/selectionNames.md) · [allLODs](../commands/allLODs.md)

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