---
name: "attachTo"
type: command
status: ok
groups: ["Object Manipulation"]
arma3_since: "0.50"
locality: {"argument": "global", "effect": "global", "server_exec": false}
source: https://community.bistudio.com/wiki/attachTo
revid: 378853
updated: 2026-07-20T13:40:14Z
---

# attachTo

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

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

## Description

Attaches an object to another object.
- The offset is applied to the object center unless a memory point is provided, in which case the offset will be applied to the memory point position.
- If no offset is specified, the current offset between the two objects will be used.

> [!NOTE]
> - All direction commands, such as [setDir](../commands/setDir.md), [setVectorDirAndUp](../commands/setVectorDirAndUp.md), etc. for an [attached object](../commands/attachedObjects.md) should be used **relative** to the reference object's direction (i.e. in model space), e.g `_attachedObj setDir 0` will make it face the same direction as the reference object, **90** face to the right, **180** face to the back, etc.
> - Attached triggers only follow the direction of the object to which they are attached, not pitch or roll.

## Syntax

```sqf
object1 attachTo [object2, offset, memPoint, followBoneRotation]
```

**Parameters:**

- `object1`: [Object](../topics/Object.md) - object to attach
- `object2`: [Object](../topics/Object.md) or [Group](../topics/Group.md) - object to attach to; if a group is provided, its [leader](../commands/leader.md) is used
- `offset`: [PositionRelative](../topics/Position.md#positionrelative) - (Optional) the position relative to *object2*'s position
- `memPoint`: [String](../topics/String.md) - (Optional) see Selection Translations for czech selections names
- `followBoneRotation`: [Boolean](../topics/Boolean.md) - (Optional) follows the memory point's rotation (if attached to one) *(since arma3 2.02)*

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

## Examples

### Example 1

```sqf
player attachTo [car, [0, 0, 1]];
```

### Example 2

```sqf
player attachTo [tank, [0, -1, 0], "Usti hlavne"];
```

### Example 3

Automatic offset:

```sqf
ammoCrate attachTo [player];
```

### Example 4

To set orientation of attached object use [setVectorDirAndUp](../commands/setVectorDirAndUp.md) command:

```sqf
_expl1 = "DemoCharge_Remote_Ammo" createVehicle position player;
_expl1 attachTo [player, [-0.1, 0.1, 0.15], "Pelvis"];
_expl1 setVectorDirAndUp [[0.5, 0.5, 0], [-0.5, 0.5, 0]];
_expl2 = "DemoCharge_Remote_Ammo" createVehicle position player;
_expl2 attachTo [player, [0, 0.15, 0.15], "Pelvis"];
_expl2 setVectorDirAndUp [[1, 0, 0], [0, 1, 0]];
_expl3 = "DemoCharge_Remote_Ammo" createVehicle position player;
_expl3 attachTo [player, [0.1, 0.1, 0.15], "Pelvis"];
_expl3 setVectorDirAndUp [[0.5, -0.5, 0], [0.5, 0.5, 0]];
```

### Example 5

```sqf
_drill attachTo [_worker, [0.0595885,-0.00950365,-0.13495], "RightForeArmRoll", true];
_drill setVectorDirAndUp [[0.536966,-0.00438141,-0.843605],[0.345872,0.913231,0.215406]];
_radio attachTo [_worker, [-0.100003,0.069064,0.153719], "Spine3", true];
_radio setVectorDirAndUp [[-0.144569,-0.48725,0.861354],[0.039712,0.866938,0.497072]];
```

## Multiplayer

Use `_attachedObj setPosWorld getPosWorld _attachedObj` *after* [setDir](../commands/setDir.md) to synchronise direction properly over the network (see [setDir's page](../commands/setDir.md) for its MP behaviour).

## See also

[attachedTo](../commands/attachedTo.md) · [attachedObjects](../commands/attachedObjects.md) · [detach](../commands/detach.md) · [getRelPos](../commands/getRelPos.md) · [attachObject](../commands/attachObject.md) · [attachedObject](../commands/attachedObject.md) · [waypointAttachVehicle](../commands/waypointAttachVehicle.md) · [waypointAttachedVehicle](../commands/waypointAttachedVehicle.md) · [lightAttachObject](../commands/lightAttachObject.md) · [triggerAttachVehicle](../commands/triggerAttachVehicle.md) · [setVectorDir](../commands/setVectorDir.md) · [setVectorUp](../commands/setVectorUp.md) · [setVectorDirAndUp](../commands/setVectorDirAndUp.md) · [modelToWorld](../commands/modelToWorld.md) · [BIS_fnc_transformVectorDirAndUp](../functions/BIS_fnc_transformVectorDirAndUp.md) · [BIS_fnc_attachToRelative](../functions/BIS_fnc_attachToRelative.md)

## Community notes

**TeaCup** — 2011-09-17

Some objects you cannot attach anything to. To be more precise, you can attach objects to them, but the behaviour is unexpected. For instance:

```sqf
SuitcaseObject attachTo [FoldingTableObject, [0,0,0]];
```

You would expect the suitcase to jump to the pivot point of the table, and stick to it.

Instead, the suitcase will freeze in it is original position. Even if the table is moved, the suitcase will be unaffected: it will not follow the table, it will not even respond to actions it reacted to prior to being attached: pushing, being shot at, etc.. It's just an object frozen in space. In MP it is even weirder, the suitcase would turn invisible.

Dodgy objects when it comes to attaching things to them: most in Objects (small), Objects (signs), all of Objects (helpers) categories, etc.

---

**Pixinger** — 2014-03-28

If you attach an explosive charge to an object (e.g. ammobox), the charge will not detonate when you simply set the damage to 1. You must detach it before.

```sqf
private _target = myAmmoBox;
// create and attach charge
private _charge = "DemoCharge_Remote_Ammo_Scripted" createVehicle position player;
_charge attachTo [_target, [0, 0, 0.2]];
_charge setVectorDirAndUp [[0.5,0.5,0], [-0.5,0.5,0]];
// now detonate charge
detach _charge; // Important!
_charge setDamage 1;
```

---

**ffur2007slx2_5** — 2014-06-01

[attachTo](../commands/attachTo.md) overwrites [setVectorDirAndUp](../commands/setVectorDirAndUp.md) if attached obj was changed to attach another one.

```sqf
_obj attachTo [_logic,[0, 0, 0]];
_obj setVectorDirAndUp [[0, 1, 0], [0, 0, -1]];
_obj attachTo [_logic, [0, 0, 2]];        // vector no changes
_obj attachTo [_anotherOne, [0, 0, 0]];    // vector changes to default
```

---

**ondrejkuzel** — 2014-09-25

Attaching an object does not update the accessibility of a place for the AI. The command **should not** be used for positioning large static objects - the AI will simply walk through such objects.

---

**Demellion** — 2016-09-01

Using [attachTo](../commands/attachTo.md) with objects that have ragdoll physics (such as ammo boxes, containers, etc.) may cause unexpected behaviour.
When you do so, if the attached object intersect origin object, origin object may gain some **enormous collision properties** even if the collision model for the attached object is not present localy to origin object, until detached.
Vehicles may start flipping with no mass calculation (ie tank might fly), player object might gain infinite Z-vector velocity on any interaction with terrain relief and other objects.

---

**R3vo** — 2019-08-13

When attaching a unit which is playing an animation to a static object, the animation becomes laggy. Presumably because the update frequency of the static object is used.

---

**Leopard20** — 2024-05-10

To find all selection names of vehicle turrets for [attachTo](../commands/attachTo.md), you can use this script:

```sqf
params ["_veh"];
private _turretSels = [];

isNil { // make sure the code runs unscheduled
    private _cfg = configOf _veh;
    _veh = createSimpleObject [getModelInfo _veh # 1, [0,0,0]]; // create a simple object instead of the actual vehicle
    deleteVehicle _veh; // mark it for deletion in the next frame

    private _turrets = configProperties [_cfg >> "Turrets", "isClass _x", true];

    private _getSelections = {_veh selectionNames "memory" apply {[_x, _veh selectionPosition [_x, "memory"], _veh selectionVectorDirAndUp [_x, "memory"]]}};
    private _allSelections = call _getSelections;

    {
        private _gun = getText (_x >> "gun");
        _veh animate [_gun, 0.4, true];
        private _newSels = call _getSelections;
        _turretSels append (_newSels - _allSelections);
        _veh animate [_gun, 0, true];
    } forEach _turrets;
};

_turretSels = _turretSels apply { _x # 0 };
_turretSels arrayIntersect _turretSels
```

Just pass your vehicle to this code, for example, like this:

```sqf
[myVehicle] call MY_fnc_getTurretSelections; // MY_fnc_getTurretSelections is the above function
```

If you simply need the end point of the gun(s), use this code instead:

```sqf
params ["_veh"];
configProperties [configOf _veh >> "Turrets", "isClass _x", true] apply { getText (_x >> "gunBeg") };
```

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