The unit will not be created if the passed group does not exist (a.k.a grpNull);
this can happen if createGroup fails because the group limit has been reached (see createGroup for respective game limits).
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 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)
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 may solve the problem.
However, some commands such as setUnitPos only work if run before the join.
position: Object, Group or Position or Position2D - location where to create the unit. In case of Group, the groupleader's position is used. The Z component of the position is ignored and the unit is always placed on the surface.
"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). 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:
group: Group - existing group the new unit will join
init: String - (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.
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).
Do not use local variables inside the init code as they are not available in multiplayer.
skill: Number - (Optional, default 0.5) unit skill
rank: String - (Optional, default "PRIVATE") unit rank
Returns:
Warning
Nothing - this syntax does not return a unit reference! See Example 7 for a workaround.
Since Arma 3 v1.86: If you want to place a module with createUnit, you have to ensure that the module gets activated automatically by setting BIS_fnc_initModules_disableAutoActivation to false, e.g:
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 is local.
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 as the side of the group 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:
// real example of the bad code"O_Soldier_AR_F"createUnit [positionplayer, someRemoteGroup, "thisUnit = this"];
publicVariable"thisUnit";
hintstrisNil"thisUnit"; // true!// the unit reference is nil because init statement has not been executed on this client yet
fusselwurm
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.