setVehiclePosition: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\[\[Category:[ _]?Scripting[ _]Commands[ _]OFP[ _]Elite *(\|.*)?\]\]" to "{{GameCategory|ofpe|Scripting Commands}}")
m (Text replacement - "<sqf>([^↵][^\/]*↵[^\/]*)<\/sqf>" to "<sqf> $1 </sqf>")
 
(58 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| arma1 |Game name=
|game1= ofpe
|version1= 1.00


|1.00|Game version=
|game2= arma1
|version2= 1.00


|arg= global |Multiplayer Arguments=
|game3= arma2
|version3= 1.00


|eff= global |Multiplayer Effects=
|game4= arma2oa
|version4= 1.50


|gr1= Positions |GROUP1=
|game5= tkoh
|version5= 1.00


|gr2= Object Manipulation |GROUP2=
|game6= arma3
____________________________________________________________________________________________
|version6= 0.50


| Moves the object to a given position (same as [[createVehicle]] placement algorithm). Uses either the position that's defined by the ''position'' param, or one of the marker positions from the markers array. The object is placed inside a circle with ''position'' as its center and ''placement'' as its radius. The type of placement could also be controlled with ''special''.
|arg= global
<br><br>
If position is in water and vehicle can float, it is placed on water surface, otherwise it is placed on the ground, even if ground is under water. If roof surfaces support walking, units will be placed on roofs if such position is given. |DESCRIPTION=
____________________________________________________________________________________________


| object '''setVehiclePosition''' [position, markers, placement, special] |SYNTAX=
|eff= global


|p1= object: [[Object]] |PARAMETER1=
|gr1= Positions
|p2= [position, markers, placement, special]: [[Array]] |PARAMETER2=


|p3= position: [[PositionATL]] ([[PositionAGL]] if boat or amphibious), [[Position2D]], or [[Object]] - Desired placement position. If object is given, object position is used for ''position''. Normally only ''x'' and ''y'' are considered, unless "CAN_COLLIDE" is used for special placement.|PARAMETER3=
|gr2= Object Manipulation


|p4= markers: [[Array]] of [[String]]s - If the markers array contains one or more marker names, the position is chosen randomly and could be one of the marker positions or just the supplied main position. If marker had z coordinate set with [[setMarkerPos]], the vehicle will be placed on the nearest surface below this z coordinate |PARAMETER4=
|descr= Moves the object to a given position (same as [[createVehicle]] placement algorithm). Uses either the position that's defined by the ''position'' param, or one of the marker positions from the markers array. The object is placed inside a circle with ''position'' as its center and ''placement'' as its radius. The type of placement could also be controlled with ''special''.<br><br>
If position is in water and the vehicle can float, it is placed on water surface, otherwise it is placed on the ground, even if the ground is under water. If roof surfaces support walking, units will be placed on roofs if such position is given.


|p5= placement: [[Number]] - The vehicle is randomly placed inside a circle with given position as center and placement as its radius|PARAMETER5=
|s1= object [[setVehiclePosition]] [position, markers, placement, special]


|p6= special (Optional): [[String]] - Could be one of the following:
|p1= object: [[Object]]
* <tt>"NONE"</tt> - will look for suitable empty position near given position (subject to other placement params) before placing vehicle there.
* <tt>"CAN_COLLIDE"</tt> places vehicle at given position (subject to other placement params), without checking if others objects can cross its 3D model.
* <tt>"FLY"</tt> - if vehicle is capable of flying and has crew, it will be made airborne at default height.
If ''special'' is "" or not specified, default <tt>"NONE"</tt> is used.|PARAMETER6=


| [[Boolean]] - [[true]] on success, [[false]] on failure|RETURNVALUE=
|p2= position: [[Array]] format [[Position#PositionATL|PositionATL]] ([[Position#PositionAGL|PositionAGL]] if boat or amphibious), [[Position#Introduction|Position2D]], or [[Object]] - desired placement position.
____________________________________________________________________________________________
If object is given, object position is used for ''position''. Normally only ''x'' and ''y'' are considered, unless "CAN_COLLIDE" is used for special placement
 
|x1= <code>[[player]] [[setVehiclePosition]] [<nowiki/>[1000,2000], ["Pos1","Pos2","Pos3"], 0, "CAN_COLLIDE"];</code> Will place the player at either [1000,2000], or one of the three markers positions.|EXAMPLE1=


|x2= <code>heli [[setVehiclePosition]] [<nowiki/>[[player]], [], 0, "FLY"];</code>|EXAMPLE2=
|p3= markers: [[Array]] of [[String]]s - if the markers array contains one or more marker names, the position is chosen randomly and could be one of the marker positions or just the supplied main position.
If marker had z coordinate set with [[setMarkerPos]], the vehicle will be placed on the nearest surface below this z coordinate


|x3= <code>_cam = "camera" [[camCreate]] [0,0,0];
|p4= placement: [[Number]] - the vehicle is randomly placed inside a circle with given position as center and placement as its radius
_cam [[setDir]] [[random]] 360;
_cam [[setVehiclePosition]] [<nowiki/>[5000,5000], [], 1000, "NONE"];
_cam [[setPosWorld]] ([[getPosWorld]] _cam [[vectorAdd]] [0,0,1.8]);
_cam [[cameraEffect]] ["Internal", "Back"];</code>|EXAMPLE3


|p5= special: [[String]] - (Optional, default "NONE") can be one of the following:
* {{hl|"NONE"}} - will look for suitable empty position near given position (subject to other placement params) before placing vehicle there.
* {{hl|"CAN_COLLIDE"}} - places vehicle at given position (subject to other placement params), without checking if others objects can cross its 3D model.
* {{hl|"FLY"}} - if vehicle is capable of flying and has crew, it will be made airborne at default height.
If ''special'' is "" or not specified, default {{hl|"NONE"}} is used.


|x4= <code>[[private]] _tablePos = [[player]] [[getRelPos]] [3, 0];
|r1= [[Boolean]] - [[true]] on success, [[false]] on failure
[[private]] _table = "Land_CampingTable_F" [[createVehicle]] [0,0,0];
[[private]] _laptop = "Land_Laptop_unfolded_F" [[createVehicle]] [0,0,0];
_table [[setPos]] _tablePos;
_laptop [[setVehiclePosition]] [_tablePos [[vectorAdd]] [0.5, 0.2, 10], [], 0, "CAN_COLLIDE"];
_laptop [[attachTo]] [_table];</code>|EXAMPLE4=
____________________________________________________________________________________________


| [[setPos]], [[createUnit]], [[setPosASL]], [[setPosWorld]], [[setPosWorld]], [[createVehicle]], [[Position#setPosAGLS|setPosAGLS]] |SEEALSO=
|x1= <sqf>
// place the player at either [1000,2000], or one of the three markers positions
player setVehiclePosition [[1000,2000], ["Pos1","Pos2","Pos3"], 0, "CAN_COLLIDE"];
</sqf>


}}
|x2= <sqf>heli setVehiclePosition [player, [], 0, "FLY"];</sqf>


<h3 style="display:none">Notes</h3>
|x3= <sqf>
<dl class="command_description">
_cam = "camera" camCreate [0,0,0];
<!-- Note Section BEGIN -->
_cam setDir random 360;
_cam setVehiclePosition [[5000,5000], [], 1000, "NONE"];
_cam setPosWorld (getPosWorld _cam vectorAdd [0,0,1.8]);
_cam cameraEffect ["Internal", "Back"];
</sqf>


<!-- Note Section END -->
|x4= <sqf>
</dl>
private _tablePos = player getRelPos [3, 0];
private _table = "Land_CampingTable_F" createVehicle [0,0,0];
private _laptop = "Land_Laptop_unfolded_F" createVehicle [0,0,0];
_table setPos _tablePos;
_laptop setVehiclePosition [_tablePos vectorAdd [0.5, 0.2, 10], [], 0, "CAN_COLLIDE"];
_laptop attachTo [_table];
</sqf>


<h3 style="display:none">Bottom Section</h3>
|seealso= [[setPos]] [[createUnit]] [[setPosASL]] [[setPosWorld]] [[setPosWorld]] [[createVehicle]] [[Position#setPosAGLS|setPosAGLS]]
[[Category:Scripting Commands|SETVEHICLEPOSITION]]
}}
{{GameCategory|ofpe|Scripting Commands}}
{{GameCategory|arma1|Scripting Commands}}
{{GameCategory|arma2|Scripting Commands}}
{{GameCategory|arma3|Scripting Commands}}
{{GameCategory|tkoh|Scripting Commands}}


<!-- CONTINUE Notes -->
{{Note
<dl class="command_description">
|user= Killzone_Kid
<dd class="notedate">Posted on June 24, 2015 - 15:43 (UTC)</dd>
|timestamp= 20150624154300
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
|text= If you need to set [[direction]] as well, set it before using [[setVehiclePosition]]. The command will use existing dir of the object for its calculations.
<dd class="note">
<sqf>
If you need to set [[direction]] as well, set it before using [[setVehiclePosition]]. The command will use existing dir of the object for its calculations.
player setDir random 360;
<code>[[player]] [[setDir]] [[random]] 360;
player setVehiclePosition [player, [], 100, "none"];
[[player]] [[setVehiclePosition]] [<nowiki/>[[player]], [], 100, "none"];</code>
</sqf>  
</dd>
}}
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 11:34, 3 September 2024

Hover & click on the images for description

Description

Description:
Moves the object to a given position (same as createVehicle placement algorithm). Uses either the position that's defined by the position param, or one of the marker positions from the markers array. The object is placed inside a circle with position as its center and placement as its radius. The type of placement could also be controlled with special.

If position is in water and the vehicle can float, it is placed on water surface, otherwise it is placed on the ground, even if the ground is under water. If roof surfaces support walking, units will be placed on roofs if such position is given.
Groups:
PositionsObject Manipulation

Syntax

Syntax:
object setVehiclePosition [position, markers, placement, special]
Parameters:
object: Object
position: Array format PositionATL (PositionAGL if boat or amphibious), Position2D, or Object - desired placement position. If object is given, object position is used for position. Normally only x and y are considered, unless "CAN_COLLIDE" is used for special placement
markers: Array of Strings - if the markers array contains one or more marker names, the position is chosen randomly and could be one of the marker positions or just the supplied main position. If marker had z coordinate set with setMarkerPos, the vehicle will be placed on the nearest surface below this z coordinate
placement: Number - the vehicle is randomly placed inside a circle with given position as center and placement as its radius
special: String - (Optional, default "NONE") can be one of the following:
  • "NONE" - will look for suitable empty position near given position (subject to other placement params) before placing vehicle there.
  • "CAN_COLLIDE" - places vehicle at given position (subject to other placement params), without checking if others objects can cross its 3D model.
  • "FLY" - if vehicle is capable of flying and has crew, it will be made airborne at default height.
If special is "" or not specified, default "NONE" is used.
Return Value:
Boolean - true on success, false on failure

Examples

Example 1:
// place the player at either [1000,2000], or one of the three markers positions player setVehiclePosition [[1000,2000], ["Pos1","Pos2","Pos3"], 0, "CAN_COLLIDE"];
Example 2:
heli setVehiclePosition [player, [], 0, "FLY"];
Example 3:
_cam = "camera" camCreate [0,0,0]; _cam setDir random 360; _cam setVehiclePosition [[5000,5000], [], 1000, "NONE"]; _cam setPosWorld (getPosWorld _cam vectorAdd [0,0,1.8]); _cam cameraEffect ["Internal", "Back"];
Example 4:
private _tablePos = player getRelPos [3, 0]; private _table = "Land_CampingTable_F" createVehicle [0,0,0]; private _laptop = "Land_Laptop_unfolded_F" createVehicle [0,0,0]; _table setPos _tablePos; _laptop setVehiclePosition [_tablePos vectorAdd [0.5, 0.2, 10], [], 0, "CAN_COLLIDE"]; _laptop attachTo [_table];

Additional Information

See also:
setPos createUnit setPosASL setPosWorld setPosWorld createVehicle setPosAGLS

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
Killzone_Kid - c
Posted on Jun 24, 2015 - 15:43 (UTC)
If you need to set direction as well, set it before using setVehiclePosition. The command will use existing dir of the object for its calculations.
player setDir random 360; player setVehiclePosition [player, [], 100, "none"];