setDir: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "{{Command " to "{{RV|type=command ")
m (Format to new RV template)
Line 1: Line 1:
{{RV|type=command
{{RV|type=command


| ofp
|game1= ofp


|1.00
|version1= 1.00


|arg= local
|arg= local
Line 11: Line 11:
|gr1= Object Manipulation
|gr1= Object Manipulation


| 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.
|descr= 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.


| object '''setDir''' heading
|s1= object '''setDir''' heading


|p1= object: [[Object]]
|p1= object: [[Object]]
|p2= heading: [[Number]]
|p2= heading: [[Number]]


| [[Nothing]]
|r1= [[Nothing]]


|x1 = <code>unit1 [[setDir]] 45; {{codecomment|// will set unit1 to face North-East}}</code>
|x1= <code>unit1 [[setDir]] 45; {{cc|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>unit1 [[setDir]] -675; {{cc|will also set unit1 to face North-East ({{=}} 45-360-360)}}</code>


|x3 = <code>unit1 [[setDir]] 30;
|x3 = <code>unit1 [[setDir]] 30;
unit1 [[setFormDir]] 30;{{codecomment|// needed for AI to keep the given direction}}</code>
unit1 [[setFormDir]] 30;{{cc|needed for AI to keep the given direction}}</code>


| [[getDir]], [[direction]], [[setFormDir]], [[setVectorDir]], [[setVectorDirAndUp]]
|seealso= [[getDir]], [[direction]], [[setFormDir]], [[setVectorDir]], [[setVectorDirAndUp]]


|mp= See notes below for more details on [[setDir]] behaviour.}}
|mp= See notes below for more details on [[setDir]] behaviour.}}
Line 35: Line 35:




<dd class="notedate">Posted on May 9, 2007 - 20:43 CET
<dd class="notedate">Posted on May 9, 2007 - 20:43 CET</dd>
<dt class="note">[[User:Manny|Manny]]
<dt class="note">[[User:Manny|Manny]]</dt>
<dd class="note">
<dd class="note">
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>
</dd>


 
<dd class="notedate">Posted on January 9, 2009 - 22:21</dd>
<dd class="notedate">Posted on January 9, 2009 - 22:21
<dt class="note">[[User:Killswitch|Killswitch]]</dt>
<dt class="note">[[User:Killswitch|Killswitch]]
<dd class="note">
<dd class="note">
In ArmA, the effect of [[setDir]] is synchronized across the network.
In ArmA, the effect of [[setDir]] is synchronized across the network.
</dd>


 
<dd class="notedate">Posted on April 5th, 2011</dd>
<dd class="notedate">Posted on April 5th, 2011
<dt class="note">[[User:kju|kju]]</dt>
<dt class="note">[[User:kju|kju]]
<dd class="note">
<dd class="note">
In OA 1.59 the comment of Manny still holds true for [[createVehicle]]'d empty vehicles by the server.
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.
For the player object a local [[setDir]] alone is enough.
</dd>


 
<dd class="notedate">Posted on November 25, 2013</dd>
<dd class="notedate">Posted on November 25, 2013
<dt class="note">[[User:Killzone_Kid|Killzone_Kid]]</dt>
<dt class="note">[[User:Killzone_Kid|Killzone_Kid]]
<dd class="note">
<dd class="note">
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.
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.
Line 64: Line 64:
_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.
</dd>


 
<dd class="notedate">Posted on November 27, 2013</dd>
<dd class="notedate">Posted on November 27, 2013
<dt class="note">[[User:Killzone_Kid|Killzone_Kid]]</dt>
<dt class="note">[[User:Killzone_Kid|Killzone_Kid]]
<dd class="note">
<dd class="note">
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]].
</dd>


 
<dd class="notedate">Posted on February 9, 2018 - 14:57 (UTC)</dd>
<dd class="notedate">Posted on February 9, 2018 - 14:57 (UTC)
<dt class="note">[[User:Tankbuster|Tankbuster]]</dt>
<dt class="note">[[User:Tankbuster|Tankbuster]]
<dd class="note">
<dd class="note">
[[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.
 
</dd>


<!-- Note Section END -->
<!-- Note Section END -->
</dl>
</dl>


[[Category:Scripting Commands|SETDIR]]
[[Category:Scripting Commands OFP 1.46|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.96|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.99|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.99|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.96|SETDIR]]
[[Category:Scripting Commands OFP 1.46|SETDIR]]
{{GameCategory|arma1|Scripting Commands}}
{{GameCategory|arma1|Scripting Commands}}
{{GameCategory|arma2|Scripting Commands}}
{{GameCategory|arma2|Scripting Commands}}
{{GameCategory|arma3|Scripting Commands}}
{{GameCategory|arma3|Scripting Commands}}
{{GameCategory|tkoh|Scripting Commands}}
{{GameCategory|tkoh|Scripting Commands}}

Revision as of 00:52, 30 January 2021

Hover & click on the images for description

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.
Multiplayer:
See notes below for more details on setDir behaviour.
Groups:
Object Manipulation

Syntax

Syntax:
object setDir heading
Parameters:
object: Object
heading: Number
Return Value:
Nothing

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)
Example 3:
unit1 setDir 30; unit1 setFormDir 30;// needed for AI to keep the given direction

Additional Information

See also:
getDirdirectionsetFormDirsetVectorDirsetVectorDirAndUp

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 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 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.
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 get confused and will stop detecting obstacles if setDir is called after setPos.
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.