createUnit: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Bot: Replacing category Scripting Commands Arma 3 with Arma 3: Scripting Commands)
Line 70: Line 70:


<h3 style="display:none">Bottom Section</h3>
<h3 style="display:none">Bottom Section</h3>
[[Category:Scripting Commands|CREATEUNIT]]
[[Category:Scripting Commands OFP 1.99|CREATEUNIT]]
[[Category:Scripting Commands OFP 1.96|CREATEUNIT]]
[[Category:Scripting Commands OFP 1.46|CREATEUNIT]]
[[Category:Scripting Commands ArmA|CREATEUNIT]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Command_Group:_Object_Manipulation|{{uc:{{PAGENAME}}}}]]
<!-- CONTINUE Notes -->
<!-- CONTINUE Notes -->
<dl class="command_description">
<dl class="command_description">
Line 123: Line 112:
</dl>
</dl>
<!-- DISCONTINUE Notes -->
<!-- DISCONTINUE Notes -->
[[Category:Scripting Commands|CREATEUNIT]]
[[Category:Scripting Commands OFP 1.99|CREATEUNIT]]
[[Category:Scripting Commands OFP 1.96|CREATEUNIT]]
[[Category:Scripting Commands OFP 1.46|CREATEUNIT]]
[[Category:Scripting Commands ArmA|CREATEUNIT]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Arma 3: Scripting Commands]]
[[Category:Scripting Commands Take On Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Command Group: Object Manipulation|{{uc:{{PAGENAME}}}}]]

Revision as of 18:13, 3 December 2018

Hover & click on the images for description

Description

Description:
Create unit of a class that's defined in CfgVehicles. The Group parameter MUST be an existing group or the unit won't be created.
Groups:
Uncategorised

Syntax

Syntax:
group createUnit [type, position, markers, placement, special]
Parameters:
group: Group - Existing group new unit will join
[type, position, markers, placement, special]: Array
type: String - Class name of unit to be created as per CfgVehicles
position: Position, Position2D, Object or Group - Location unit is created at. In case of Group position of the group leader is used
markers: Array - Placement markers
placement: Number - Placement radius
special: String - Unit placement special, one of:
  • "NONE" - The unit will be created at the first available free position nearest to given position
  • "FORM" - The unit will be created in formation around the group leader, regardless of the passed position
  • "CAN_COLLIDE" - The unit will be created exactly at passed position
  • "CARGO" - The unit will be created in cargo of the group's vehicle, regardless of the passed position. If group has no vehicle or there is no cargo space available, the unit will be placed according to "NONE". To check available cargo space use:_hasCargo = _veh emptyPositions "CARGO" > 0;
Return Value:
Object - The reference to created unit

Alternative Syntax

Syntax:
type createUnit [position, group, init, skill, rank]
Parameters:
type: String - Class name of unit to be created as per CfgVehicles
[position, group, init, skill, rank]: Array
position: Position, Position2D, Object or Group - Location unit is created at. In case of Group position of the group leader is used
group: Group - Existing group new unit will join
init (Optional): String - Command to be executed upon creation of unit. Parameter this is set to the created unit and passed to the code. Default: ""
skill (Optional): Number - Unit skill. Default: 0.5
rank (Optional): String - Unit rank. Default: PRIVATE
Return Value:
Nothing - NOTE: THIS SYNTAX RETURNS NO UNIT REFERENCE!

Examples

Example 1:
_unit = group player createUnit ["B_RangeMaster_F", position player, [], 0, "FORM"];
Example 2:
"B_RangeMaster_F" createUnit [position player, group player];
Example 3:
"B_RangeMaster_F" createUnit [getMarkerPos "barracks", _groupAlpha];
Example 4:
"B_RangeMaster_F" createUnit [getMarkerPos "marker_1", _groupAlpha, "loon1 = this; this addWeapon 'BAF_L85A2_RIS_SUSAT'", 0.6, "corporal"];

Additional Information

See also:
createCentercreateGroupcreateVehiclesetVehiclePosition

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note

Notes

Posted on August 13, 2006 - 12:32
raedor
To give a newly created unit a name, put "newUnit = this" in the init field.
Posted on 18:41, 5 April 2007 (CEST)
Shuko
The eventhandlers added with addEventHandler in the init parameter will only fire locally on the machine where this creation command is called from.
Posted on December 24, 2007 - 00:33
MulleDK13
If you do not wish it to be in a group, you can create a gamelogic and group it to that.
Note: The unit will deny to move away from the gamelogic.

Bottom Section

Posted on August 27, 2015 - 02:25 (UTC)
Austin medic
In order to solve the above problem you can simply group it to the game logic as stated, then group it to grpNull

e.g myUnit join myGroupLogic; myUnit join grpNull
Posted on 21 December 2006
Sbsmac
Although this command takes a group as an argument, you need to use the join command if you want the created units to perform actions such as move. For example: comment "Create a new soldier within 100m of the player and cause them to run towards the player" ; _grp = createGroup west; unit = _grp createUnit ["SoldierWB", position player, [], 100, "FORM"] ; [unit] join _grp ; unit move position player ; However, some commands such as setUnitPos only work if run before the join.
Posted on 11 March 2011
kju
Comment above about 'an additional join required' is no longer true for Operation Arrowhead.
Posted on 27th Nov 2016
Ffur2007slx2_5
(A3 v1.64)The side of created unit by this command fallows the fraction from its config and won’t be affected by the side of the passed group parameter which is created by createGroup on the fly without entities. _grp = createGroup east; // O Alpha 1-1 _ap = _grp createUnit [ “C_man_p_beggar_F”, position player, [], 0, "FORM"]; //the side of _ap is still CIV not EAST. We can use join command family or fill the _grp with entities in advance to set _ap to our desired side.