setDir: Difference between revisions
Jump to navigation
Jump to search
Tankbuster (talk | contribs) No edit summary |
Lou Montana (talk | contribs) m (Example and description correction) |
||
Line 11: | Line 11: | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| Sets object heading. Angles are measured in degrees clockwise from north | | Sets object heading. Angles are measured in degrees clockwise from north, and regular range goes from 0 to 360 (0° {{=}} N, 90° {{=}} E, 180° {{=}} S, 270° {{=}} W). Negative angles represent a counter-clockwise angle. |= Description | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
Line 21: | Line 21: | ||
| [[Nothing]] |= Return value | | [[Nothing]] |= Return value | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
|x1 = <code> | |x1 = <code>unit1 [[setDir]] 45 {{codecomment|// will set unit1 to face North-East}}</code> | ||
|x2 = <code>unit1 [[setDir]] -675 {{codecomment|// will also set unit1 to face North-East ({{=}} 45-360-360)}}</code> | |||
|x2 = <code> | |||
| [[getDir]], [[direction]], [[setFormDir]], [[setVectorDir]], [[setVectorDirAndUp]] |= See also | | [[getDir]], [[direction]], [[setFormDir]], [[setVectorDir]], [[setVectorDirAndUp]] |= See also |
Revision as of 15:06, 13 March 2018
Description
- Description:
- Sets object heading. Angles are measured in degrees clockwise from north, and regular range goes from 0 to 360 (0° = N, 90° = E, 180° = S, 270° = W). Negative angles represent a counter-clockwise angle.
- Groups:
- Uncategorised
Syntax
Examples
- Example 1:
unit1 setDir 45 // will set unit1 to face North-East
- Example 2:
unit1 setDir -675 // will also set unit1 to face North-East (= 45-360-360)
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 November 27, 2013
- Killzone_Kid
- Make sure you setDir BEFORE you set position. Setting direction after set position could lead to unpredictable behaviour. For example main part of the hospital building in Arma 3 can lose collision detection near both side entrances. AI will also can get confused and will stop detecting obstacles if setDir called after setPos.
- Posted on May 9, 2007 - 20:43 CET
- Manny
-
Though effects of this command remain local, you can do a setPos afterwards to synchronize the direction on all machines in MP.
myObj setDir 90; myObj setPos getPos myObj;
- Posted on January 9, 2009 - 22:21
- Killswitch
- In ArmA, the effect of setDir is synchronized across the network.
- Posted on April 5th, 2011
- kju
- In OA 1.59 the comment of Manny still holds true for createVehicle'd empty vehicles by the server. For the player object a local setDir alone is enough.
- Posted on July 10, 2010 - 16:34
- Shuko
- In ArmA 2 OA, this command only makes the unit glance momentarily to the direction. To change his heading more permanently use setFormDir.
- Posted on August 28, 2013
- Killzone_Kid
-
Be careful letting the command to do the conversion for you when the angle is < 0 or > 360
player setDir 360+1; hint str direction player; //1 player setDir -360+1; hint str direction player; //1.00001 player setDir 360*5+1; hint str direction player; //1.00002 player setDir -360*5+1; hint str direction player; //0.999972 player setDir 360*10+1; hint str direction player; //0.999876 player setDir -360*10+1; hint str direction player; //1 player setDir 360*100000+1; hint str direction player; //358.24 player setDir -360*100000+1; hint str direction player; //1.76001 player setDir 360*10000000+1; hint str direction player; //298.591 player setDir -360*10000000+1; hint str direction player; //61.4094
- Posted on November 25, 2013
- Killzone_Kid
-
In Arma 3, setDir affects vectorUp, vectorDir and velocity of the object it applied to. While this is not noticeable with stationary objects, a moving objects will have its orientation and velocity reset. So if you are planning on using setDir on a moving object, make sure you read the velocity value before and restore it after if you want the object to continue to move.
_vel = velocity _object; _object setDir 45; _object setVelocity _vel;
With orientation it is a bit more complicated. setDir resets vectorUp to [0,0,1] and changes vectorDir accordingly to accommodate set direction. If your object's vectorUp is not [0,0,1] and you want to keep it this way, then you have to use setVectorDirAndUp to change object's direction not setDir. This is also the reason why it is better to use setVectorDirAndUp instead of setDir on attached objects for a better control of object's orientation.
Bottom Section
- Posted on November 22, 2014 - 20:05 (UTC)
- Killzone Kid
-
To setDir for AI unit, setFormDir first:
_ai setFormDir 180; _ai setDir 180;
- Posted on February 9, 2018 - 14:57 (UTC)
- Tankbuster
- setDir is not propagated across the network when used on mines. Clients will see mines facing zero. This is especially noticeable on tripwire mines. Use remoteexec to run the setdir command on the mine for all clients.
Categories:
- Scripting Commands
- Introduced with Operation Flashpoint version 1.00
- Operation Flashpoint: New Scripting Commands
- Operation Flashpoint: Scripting Commands
- Command Group: Uncategorised
- Scripting Commands: Global Effect
- Scripting Commands OFP 1.99
- Scripting Commands OFP 1.96
- Scripting Commands OFP 1.46
- Scripting Commands ArmA
- Scripting Commands ArmA2
- Scripting Commands Arma 3
- Scripting Commands Take On Helicopters