setVehiclePosition: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "<code>([^ ]*)\[\[([a-zA-Z][a-zA-Z0-9_]+)\]\]([^ ]*)<\/code>" to "<code>$1$2$3</code>") |
Lou Montana (talk | contribs) m (Text replacement - "<sqf>([^↵][^\/]*↵[^\/]*)<\/sqf>" to "<sqf> $1 </sqf>") |
||
(30 intermediate revisions by 2 users not shown) | |||
Line 37: | Line 37: | ||
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 | 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 | ||
|p3= markers: [[Array]] of [[String]]s - | |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 | If marker had z coordinate set with [[setMarkerPos]], the vehicle will be placed on the nearest surface below this z coordinate | ||
|p4= placement: [[Number]] - | |p4= placement: [[Number]] - the vehicle is randomly placed inside a circle with given position as center and placement as its radius | ||
|p5= special: [[String]] - (Optional, default "NONE") can be one of the following: | |p5= special: [[String]] - (Optional, default "NONE") can be one of the following: | ||
Line 50: | Line 50: | ||
|r1= [[Boolean]] - [[true]] on success, [[false]] on failure | |r1= [[Boolean]] - [[true]] on success, [[false]] on failure | ||
|x1= < | |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= < | |x2= <sqf>heli setVehiclePosition [player, [], 0, "FLY"];</sqf> | ||
|x3= < | |x3= <sqf> | ||
_cam | _cam = "camera" camCreate [0,0,0]; | ||
_cam | _cam setDir random 360; | ||
_cam | _cam setVehiclePosition [[5000,5000], [], 1000, "NONE"]; | ||
_cam | _cam setPosWorld (getPosWorld _cam vectorAdd [0,0,1.8]); | ||
_cam cameraEffect ["Internal", "Back"]; | |||
</sqf> | |||
|x4= < | |x4= <sqf> | ||
private _tablePos = player getRelPos [3, 0]; | |||
private _table = "Land_CampingTable_F" createVehicle [0,0,0]; | |||
_table | private _laptop = "Land_Laptop_unfolded_F" createVehicle [0,0,0]; | ||
_laptop | _table setPos _tablePos; | ||
_laptop | _laptop setVehiclePosition [_tablePos vectorAdd [0.5, 0.2, 10], [], 0, "CAN_COLLIDE"]; | ||
_laptop attachTo [_table]; | |||
</sqf> | |||
|seealso= | |seealso= [[setPos]] [[createUnit]] [[setPosASL]] [[setPosWorld]] [[setPosWorld]] [[createVehicle]] [[Position#setPosAGLS|setPosAGLS]] | ||
}} | }} | ||
Line 74: | Line 81: | ||
|timestamp= 20150624154300 | |timestamp= 20150624154300 | ||
|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. | |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. | ||
< | <sqf> | ||
player setDir random 360; | |||
player setVehiclePosition [player, [], 100, "none"]; | |||
</sqf> | |||
}} | }} |
Latest revision as of 11:34, 3 September 2024
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.
- 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:
- 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
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
- 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.
Categories:
- Scripting Commands
- Introduced with Operation Flashpoint: Elite version 1.00
- Operation Flashpoint: Elite: New Scripting Commands
- Operation Flashpoint: Elite: Scripting Commands
- ArmA: Armed Assault: Scripting Commands
- Arma 2: Scripting Commands
- Arma 2: Operation Arrowhead: Scripting Commands
- Take On Helicopters: Scripting Commands
- Arma 3: Scripting Commands
- Command Group: Positions
- Command Group: Object Manipulation
- Scripting Commands: Global Effect