---
name: "createUnit"
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/createUnit
revid: 377516
updated: 2026-01-02T06:50:26Z
---

# createUnit

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

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

## Description

Create a unit of the provided CfgVehicles class.

> [!WARNING]
> The unit will not be created if the passed group does not exist (a.k.a [grpNull](../commands/grpNull.md));
> this can happen if [createGroup](../commands/createGroup.md) fails because the **group limit has been reached** (see [createGroup](../commands/createGroup.md) for respective game limits).

|  | [#Syntax 1](../commands/createUnit.md#syntax-1) | [#Syntax 2](../commands/createUnit.md#syntax-2) |
|---|---|---|
| Group's locality | the provided group *can* be non-[local](../topics/Multiplayer_Scripting.md#locality), but a warning will be logged | the provided group **must** be [local](../topics/Multiplayer_Scripting.md#locality) |
| Unit's [side](../commands/side.md) | using a classname from a different side than the provided group will result in the unit itself being of a (config-defined) side inside a group of another side - see [#Example 6](../commands/createUnit.md#example-6) for more information | using a classname from a different side than the provided group will result in the unit being of the same side as the provided group |
| Other | the unit's init code will execute after a slight delay if the provided group is not local | this syntax does **not** return a reference to the created unit (see [#Example 7](../commands/createUnit.md#example-7)) |

> [!NOTE]
> **Armed Assault:** Operation Flashpoint v1.34 Armed Assault v1.00 This command was sometimes bugged in Operation Flashpoint or Armed Assault; an additional [join](../commands/join.md) may solve the problem.
>
> However, some commands such as [setUnitPos](../commands/setUnitPos.md) only work if run before the [join](../commands/join.md).

## Syntax

### Syntax 1

```sqf
group createUnit [type, position, markers, placement, special]
```

**Parameters:**

- `group`: [Group](../topics/Group.md) - existing group new unit will join; if the group is not [local](../commands/local.md), a warning will be logged
- `type`: [String](../topics/String.md) - classname of unit to be created as per CfgVehicles
- `position`: [Object](../topics/Object.md), [Group](../topics/Group.md) or [Position](../topics/Position.md) or [Position2D](../topics/Position.md#introduction) - location where to create the unit. In case of [Group](../topics/Group.md), the [group](../commands/group.md) [leader](../commands/leader.md)'s position is used. The Z component of the position is ignored and the unit is always placed on the surface.
- `markers`: [Array](../topics/Array.md) - placement markers
- `placement`: [Number](../topics/Number.md) - placement radius
- `special`: [String](../topics/String.md) - unit placement special, one of:
  - `"NONE"` - The unit will be created at the first available free position nearest to given position
  - `"FORM"` - Not implemented, currently functions the same as "NONE"
  - `"CAN_COLLIDE"` - The unit will be created exactly at the provided position
  - `"CARGO"` - The unit will be created in cargo of the group's vehicle, regardless of the passed position (see [#Example 5](../commands/createUnit.md#example-5)). If group has no vehicle or there is no cargo space available, the unit will be placed according to `"NONE"`. `"CARGO"` placement excludes cargo positions with personal FFV turrets. To check available cargo space use:

  |  |  |
  |---|---|
  | Arma 3 v1.34 FFV | ```sqf<br>private _hasCargo = { isNull (_x select 0) } count (fullCrew [_veh, "cargo", true]) > 0;<br>``` |
  | before | ```sqf<br>_hasCargo = _veh emptyPositions "CARGO" > 0;<br>``` |

**Returns:** [Object](../topics/Object.md) - the created unit

### Syntax 2

```sqf
type createUnit [position, group, init, skill, rank]
```

**Parameters:**

- `type`: [String](../topics/String.md) - classname of unit to be created as per CfgVehicles
- `position`: [Object](../topics/Object.md), [Group](../topics/Group.md) or [Position](../topics/Position.md) or [Position2D](../topics/Position.md#introduction) - location at which the unit is created. In case of [Group](../topics/Group.md) position of the [group](../commands/group.md) [leader](../commands/leader.md) is used
- `group`: [Group](../topics/Group.md) - existing group the new unit will join
- `init`: [String](../topics/String.md) - (Optional, default "") unit init statement, similar to unit init field in the editor. The code placed in unit init will run upon unit creation for every client on network, present and future.
  The code itself receives the reference to the created unit via local variable [this](../topics/Magic_Variables.md#this_2).

  > [!WARNING]
  > - Do not use global effect commands in a unit's *init* as it runs on every client (local effect ones are OK, e.g [setIdentity](../commands/setIdentity.md)).
  > - Do not use local variables inside the init code as they are not available in multiplayer.
- `skill`: [Number](../topics/Number.md) - (Optional, default 0.5) unit [skill](../commands/skill.md)
- `rank`: [String](../topics/String.md) - (Optional, default "PRIVATE") unit [rank](../commands/rank.md)

**Returns:** > [!WARNING]
> **[Nothing](../topics/Nothing.md)** - this syntax does **not** return a unit reference! See [#Example 7](../commands/createUnit.md#example-7) for a workaround.

## Examples

### Example 1

```sqf
_unit = group player createUnit ["B_RangeMaster_F", position player, [], 0, "NONE"];
```

### Example 2

```sqf
"B_RangeMaster_F" createUnit [position player, group player];
```

### Example 3

```sqf
"B_RangeMaster_F" createUnit [getMarkerPos "barracks", _groupAlpha];
```

### Example 4

```sqf
"B_RangeMaster_F" createUnit [
    getMarkerPos "marker_1",
    _groupAlpha,
    "loon1 = this; this addWeapon 'BAF_L85A2_RIS_SUSAT'",
    0.6,
    "corporal"
];
```

### Example 5

```sqf
_veh = "O_Quadbike_01_F" createVehicle (player getRelPos [10, 0]);
_grp = createVehicleCrew _veh;
_unit = _grp createUnit [typeOf driver _veh, _grp, [], 0, "CARGO"];
```

### Example 6

Creating a unit from a different side may lead to issues:

```sqf
_grp = createGroup east;
hint str side _grp; // EAST
_ap = _grp createUnit ["C_man_p_beggar_F", position player, [], 0, "NONE"];
hint str side _ap; // CIV, not EAST

// workaround
[_ap] joinSilent _grp;
hint str side _ap; // EAST
```

### Example 7

Reference the created unit through a global variable:

```sqf
_myUnit = "B_RangeMaster_F" createUnit [position player, group player];            // wrong - this syntax does not return a reference

"B_RangeMaster_F" createUnit [position player, group player, "myUnit = this"];    // correct - the unit is myUnit (NOT _myUnit!)
```

## Multiplayer

It is recommended to create the unit where the group is **[local](../topics/Multiplayer_Scripting.md#locality)** - use [remoteExec](../commands/remoteExec.md) if needed.

## See also

[createCenter](../commands/createCenter.md) · [createGroup](../commands/createGroup.md) · [createVehicle](../commands/createVehicle.md) · [setVehiclePosition](../commands/setVehiclePosition.md) · [create3DENEntity](../commands/create3DENEntity.md)

## Community notes

**oOKexOo** — 2018-12-08

Since Arma 3 v1.86: If you want to place a module with [createUnit](../commands/createUnit.md), you have to ensure that the module gets activated automatically by setting **[BIS_fnc_initModules](../functions/BIS_fnc_initModules.md)_disableAutoActivation** to [false](../commands/false.md), *e.g*:

```sqf
private _grp = createGroup sideLogic;
"ModuleSmokeWhite_F" createUnit [
    getPos player,
    _grp,
    "this setVariable ['BIS_fnc_initModules_disableAutoActivation', false, true];"
];
```

---

**Killzone_Kid** — 2019-03-18

Alt Syntax is the older syntax and differs in functionality from the main, newer syntax. The main difference is that the older syntax **does not** return unit reference.
This is because the unit created with Alt Syntax is created strictly where passed [group](../commands/group.md) is [local](../topics/Multiplayer_Scripting.md#locality).
This means that if the group is remote the unit will be created on the different client than the one the command was executed on and therefore it is not possible to return created unit reference immediately.
In contrast, the newer syntax allows creating units in remote groups while returning unit reference immediately, which could be unsafe and the appropriate warning is logged into *.rpt* file: `Warning: Adding units to a remote group is not safe. Please use setGroupOwner to change the group owner first.`

Another very important difference is that the older syntax (Alt Syntax) will create unit of the same [side](../commands/side.md) as the side of the [group](../commands/group.md) passed as argument.
For example, if the group is WEST and the unit faction is OPFOR of type, say `"O_Soldier_GL_F"`, the unit created will be on the WEST side as well.
In contrast, newer syntax will create the same unit on the EAST side in the WEST group, which will be treated as hostile by other group members and eliminated.

> [!WARNING]
> Beware that in MP if unit is created in remote group with older syntax, the unit init will execute on calling client sometime in the future, after the unit is created on remote client, therefore the following code will fail:
>
> ```sqf
> // real example of the bad code
> "O_Soldier_AR_F" createUnit [position player, someRemoteGroup, "thisUnit = this"];
> publicVariable "thisUnit";
> hint str isNil "thisUnit"; // true!
> // the unit reference is nil because init statement has not been executed on this client yet
> ```

---

**fusselwurm** — 2020-06-19

Arma 3 v1.98 note that even when setting the *placement special* parameter to "NONE", 3DEN-placed objects are being ignored when looking for a free position.
In other words: units will spawn within editor-placed rocks or under houses.

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