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]|
|Syntax:||group createUnit [type, position, markers, placement, special, asl, side]|
"SoldierWB" createUnit [position player, group player]
"soldierWB" createUnit [getMarkerPos "barracks", _groupAlpha]
_unit = (group player) createUnit [typeOf player, getPos player, , 0, "NONE"]
|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.