setDir: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Undo revision 293185 by Lou Montana (talk) - remove test note) Tag: Undo |
Lou Montana (talk | contribs) (This problem is Mine) |
||
Line 28: | Line 28: | ||
|gr1= Object Manipulation | |gr1= Object Manipulation | ||
|descr= Sets object heading, resetting ''object''<nowiki/>'s [[velocity]] and [[vectorUp]]. Angles are measured in degrees clockwise from north; the regular range goes from 0 to 360 (0° | |descr= Sets object heading, resetting ''object''<nowiki/>'s [[velocity]] and [[vectorUp]]. Angles are measured in degrees clockwise from north; the regular range goes from 0 to 360 (0° = N, 90° = E, 180° = S, 270° = W). Negative angles represent counter-clockwise angles. | ||
{{Feature|informative|In ''some'' earlier titles ({{ofp}}?), this command was {{Icon|localEffect|32}}.}} | |||
|pr= <nowiki/> | |||
* The effect is {{Icon|localEffect|32}} when using [[setVectorDir]] on a mine. Use a position modification to broadcast [[setDir]]'s change (see {{HashLink|#Example 2}}) | |||
* setting direction ''before'' position may lead to weird behaviours - see {{HashLink|#Notes}} | |||
|mp= See the {{HashLink|#Notes}} below | |mp= See the {{HashLink|#Notes}} below | ||
Line 46: | Line 51: | ||
|x3= <code>MyUnit [[setDir]] 30; | |x3= <code>MyUnit [[setDir]] 30; | ||
MyUnit [[setFormDir]] 30; {{cc|needed for AI to keep the given direction}}</code> | MyUnit [[setFormDir]] 30; {{cc|needed for AI to keep the given direction}}</code> | ||
|x4= <code>{{cc|provided _myMine is local}} | |||
_myMine [[setDir]] 45; | |||
_myMine [[setPosWorld]] [[getPosWorld]] _myMine; | |||
{{cc|or}} | |||
[_myMine, 45] [[remoteExec]] ["setDir"]; | |||
</code> | |||
|seealso= [[getDir]] [[direction]] [[setFormDir]] [[setVectorDir]] [[setVectorDirAndUp]] | |seealso= [[getDir]] [[direction]] [[setFormDir]] [[setVectorDir]] [[setVectorDirAndUp]] | ||
}} | }} | ||
{{Note | |||
|user= Manny | |||
|timestamp= 20070509204300 | |||
|text= Though effects of this command remain local, you can do a [[setPos]] afterwards to synchronize the direction on all machines in MP. | |||
Though effects of this command remain local, you can do a [[setPos]] afterwards to synchronize the direction on all machines in MP. | |||
<code>myObj [[setDir]] 90; | <code>myObj [[setDir]] 90; | ||
myObj [[setPos]] [[getPos]] myObj;</code> | myObj [[setPos]] [[getPos]] myObj;</code> | ||
|game= arma1 | |||
}} | |||
{{Note | |||
|user= kju | |||
|timestamp= 20010405105400 | |||
|text= In {{arma2oa}} 1.59 the comment of Manny still holds true for [[createVehicle]]'d empty vehicles by the server. | |||
In {{arma2oa}} 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. | For the player object a local [[setDir]] alone is enough. | ||
}} | |||
{{Note | |||
|user= Killzone_Kid | |||
|timestamp= 20131125114700 | |||
|text= In {{arma3}}, [[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. | |||
In {{arma3}}, [[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. | |||
<code>_vel = [[velocity]] _object; | <code>_vel = [[velocity]] _object; | ||
_object [[setDir]] 45; | _object [[setDir]] 45; | ||
_object [[setVelocity]] _vel;</code> | _object [[setVelocity]] _vel;</code> | ||
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. | 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. | ||
}} | |||
{{Note | |||
|user= Killzone_Kid | |||
|timestamp= 20131127230900 | |||
|text= 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 get confused and will stop detecting obstacles if [[setDir]] is called after [[setPos]]. | |||
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 get confused and will stop detecting obstacles if [[setDir]] is called after [[setPos]]. | }} | ||
{{Note | |||
|user= Tankbuster | |||
|timestamp= 20180209145700 | |||
|text= [[setDir]] is not propagated across the network when used on mines. Clients will see mines facing zero. This is especially noticeable on tripwire mines.<br> | |||
[[setDir]] is not propagated across the network when used on mines. Clients will see mines facing zero. This is especially noticeable on tripwire mines.<br> | |||
Use [[remoteExec]] to run the [[setDir]] command on the mine for all clients. | Use [[remoteExec]] to run the [[setDir]] command on the mine for all clients. | ||
}} | |||
Revision as of 13:41, 18 November 2021
Description
- Description:
- Sets object heading, resetting object's velocity and vectorUp. Angles are measured in degrees clockwise from north; the regular range goes from 0 to 360 (0° = N, 90° = E, 180° = S, 270° = W). Negative angles represent counter-clockwise angles.
- Multiplayer:
- See the Notes below
- Problems:
-
- The effect is LELocal when using setVectorDir on a mine. Use a position modification to broadcast setDir's change (see Example 2)
- setting direction before position may lead to weird behaviours - see Notes
- Groups:
- Object Manipulation
Syntax
Examples
- Example 1:
myUnit setDir 45; // will set myUnit to face North-East
- Example 2:
myUnit setDir -675; // will also set myUnit to face North-East (= 45-360-360)
- Example 3:
MyUnit setDir 30; MyUnit setFormDir 30; // needed for AI to keep the given direction
- Example 4:
// provided _myMine is local _myMine setDir 45; _myMine setPosWorld getPosWorld _myMine; // or [_myMine, 45] remoteExec ["setDir"];
Additional Information
- See also:
- getDir direction setFormDir setVectorDir setVectorDirAndUp
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 May 09, 2007 - 20:43 (UTC)
-
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 Apr 05, 2001 - 10:54 (UTC)
- In Arma 2: Operation Arrowhead 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 Nov 25, 2013 - 11:47 (UTC)
-
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.
- Posted on Nov 27, 2013 - 23:09 (UTC)
- 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 get confused and will stop detecting obstacles if setDir is called after setPos.
- Posted on Feb 09, 2018 - 14:57 (UTC)
-
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
- 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: Object Manipulation
- Scripting Commands: Global Effect