createUnit: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) (Page fix and comments cleanup) |
Lou Montana (talk | contribs) m (Changed warning location about grpNull issue) |
||
Line 12: | Line 12: | ||
{{Important| <div style{{=}}"float: left; margin-right: 0.5em;">{{GVI|ofp|1.34}} {{GVI|arma|1.00}}</div> | {{Important| <div style{{=}}"float: left; margin-right: 0.5em;">{{GVI|ofp|1.34}} {{GVI|arma|1.00}}</div> | ||
This command could be bugged in {{ofp}} or {{arma}} ; an additional [[join]] may solve the problem.<br /> | This command could be bugged in {{ofp}} or {{arma}} ; an additional [[join]] may solve the problem.<br /> | ||
However, some commands such as [[setUnitPos]] only work if run before the [[join]].}} |Description= | However, some commands such as [[setUnitPos]] only work if run before the [[join]].}} | ||
{{Warning|The unit won't be created '''if the passed group doesn't exist''' (a.k.a [[grpNull]]); this can happen if [[createGroup]] fails because the '''group limit has been reached'''.}} |Description= | |||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
|group [[createUnit]] [type, position, markers, placement, special] |Syntax= | |group [[createUnit]] [type, position, markers, placement, special] |Syntax= | ||
|p1= group: [[Group]] - Existing group new unit will join | |p1= group: [[Group]] - Existing group new unit will join |Parameter 1= | ||
|p2= [type, position, markers, placement, special]: [[Array]] |Parameter 2= | |p2= [type, position, markers, placement, special]: [[Array]] |Parameter 2= | ||
|p3= type: [[String]] - Class name of unit to be created as per [[CfgVehicles]] |Parameter 3= | |p3= type: [[String]] - Class name of unit to be created as per [[CfgVehicles]] |Parameter 3= | ||
Line 27: | Line 28: | ||
* <tt>"FORM"</tt> - The unit will be created in formation around the group leader, regardless of the passed position | * <tt>"FORM"</tt> - The unit will be created in formation around the group leader, regardless of the passed position | ||
* <tt>"CAN_COLLIDE"</tt> - The unit will be created exactly at passed position | * <tt>"CAN_COLLIDE"</tt> - The unit will be created exactly at passed position | ||
* <tt>"CARGO"</tt> - 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 <tt>"NONE"</tt>. To check available cargo space use:<code>_hasCargo = _veh [[emptyPositions]] "CARGO" > 0;</code>|Parameter 7= | * <tt>"CARGO"</tt> - 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 <tt>"NONE"</tt>. To check available cargo space use:<code>_hasCargo = _veh [[emptyPositions]] "CARGO" > 0;</code> |Parameter 7= | ||
| [[Object]] - The created unit |Return value= | | [[Object]] - The created unit |Return value= | ||
Line 42: | Line 43: | ||
|r2= {{Warning|'''[[Nothing]]''' - This syntax does NOT return a unit reference!<br /> | |r2= {{Warning|'''[[Nothing]]''' - This syntax does NOT return a unit reference!<br /> | ||
In order to reference this unit, you can use {{Inline code|newUnit {{=}} this}} in the ''init'' field}}|Return value 2= | In order to reference this unit, you can use {{Inline code|newUnit {{=}} this}} in the ''init'' field}} |Return value 2= | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
Revision as of 22:57, 9 January 2019
Description
- Description:
- Create a unit of class that is defined in CfgVehicles.
- 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 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: String - (Optional, default "") Command to be executed locally upon creation of the unit. Parameter this is set to the created unit and passed to the code.
- skill: Number - (Optional, default 0.5) Unit skill
- rank: String - (Optional, default "PRIVATE") Unit rank
- Return Value:
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
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 27th Nov 2016
- Ffur2007slx2_5
-
1.64 The side of the created unit by this command uses its config's side and not the side of a passed empty group created by createGroup:
_grp = createGroup east; hint str side _grp; // EAST _ap = _grp createUnit [ “C_man_p_beggar_F”, position player, [], 0, "FORM"]; hint str side _ap; // CIV, not EAST
We can use join command or fill the _grp with entities in advance to set _ap to the desired side. - Posted on 8th Dec 2018
- oOKexOo
-
Since 1.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:
private _grp = createGroup sideLogic; "ModuleSmokeWhite_F" createUnit [ getPos player, _grp, "this setVariable ['BIS_fnc_initModules_disableAutoActivation', false, true];" ];
Categories:
- Scripting Commands
- Introduced with Operation Flashpoint version 1.34
- Operation Flashpoint: New Scripting Commands
- Operation Flashpoint: Scripting Commands
- Command Group: Uncategorised
- Scripting Commands: Global Effect
- Scripting Commands OFP 1.46
- Scripting Commands OFP 1.96
- Scripting Commands OFP 1.99
- Scripting Commands ArmA
- Scripting Commands ArmA2
- Scripting Commands Take On Helicopters
- Scripting Commands Arma 3
- Command Group: Object Manipulation