Page tree
Skip to end of metadata
Go to start of metadata

Introduced in




Creates a new unit of the specified class. The group that the new unit joins must exist already.

If there are no units in the mission yet, that are of the same side as the one that is spawned, then an appropriate createCenter has to be created first, before creating the group and the unit. For example, if an OPFOR unit is to be created, but only west units exist so far in mission:

createCenter east;
_grp = createGroup east;
east setFriend [west,0];
"vbs2_af_taliban_ak74" createUnit [getPos player, _grp];

To delete units, use deleteVehicle.


Syntax:type createUnit [position, group, init, skill, rank]
  • type: String - Type of unit to create.
  • position: Position - Data Type - Location the unit is created at.
  • group: Group - Existing group that the new unit joins (the group must exist already).
  • init: String - Command to execute on unit creation. The global variable this is set to the created unit, and can be used in the code (optional, default "").
  • skill: Number - Unit skill (optional, default 0.5).
  • rank: String - Unit rank (optional, default "PRIVATE").
Return Value:Nothing

Alternative Syntax

Syntax:group createUnit [type, position, markers, placement, special, asl, side]
  • group: Group - Existing group for the new unit to join.
  • type: String - Type of unit to create.
  • position: Position - Data Type - Location the unit is created at.
  • markers: Array - Array of markers, of which a random one is used to define the position.
  • placement: Number - Radius around the specified position, within which the unit is created.
  • special: String - Can be:
    • "NONE" - No special effects.
    • "CAN_COLLIDE" - If a unit is created close to an existing one, then the initial position is not corrected. If used with the asl parameter, then the unit can be created above the ground.
  • asl: Boolean - If true, then position is interpreted as ASL. Requires special to be set to "CAN_COLLIDE" (optional, default: false - creates a unit on the ground, no matter the z-value position).
  • side: Boolean - If true, then the unit gets the group side. If false, it gets the side specified in by type (optional, default: false) (V2.08+).
Return Value:Object


"SoldierWB" createUnit [position player, group player]
"soldierWB" createUnit [getMarkerPos "barracks", _groupAlpha]
_unit = (group player) createUnit [typeOf player, getPos player, [], 0, "NONE"]

Additional Information

See also: createCenter, createGroup, createVehicle, deleteVehicle
Multiplayer:The code in init is executed on all connected clients in multiplayer. It can be used to get around the publicVariable limitation of not being able to send strings and arrays over the network.


Posted on August 13, 2006 - 12:32
To give a newly created unit a name, put "newUnit = this" in the init field.

Posted on 18:41, 5 April 2007 (CEST)
The eventhandlers added with addEventHandler in the init parameter will only fire locally on the machine where this creation command is called from.