Entity::getRotation: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
 
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
rotationOrder refers to the order yaw pitch roll is applied<br>value ranges from 0 to 5. What you use for rotationOrder when getting must be the same as rotationOrder when setting the rotation. <br>Unsure what value corresponds to what rotation order, more testing will be needed for that.<br>------<br>rotationOrder is usually 2 in scripts<br>------<br>ENTITY::GET_ENTITY_ROTATION(Any p0, false or true);<br>if false than return from -180 to 180<br>if true than return from -90 to 90<br><br>---<br><br>As said above, the value of p1 affects the outcome. R* uses 1 and 2 instead of 0 and 1, so I marked it as an int.<br><br>What it returns is the yaw on the z part of the vector, which makes sense considering R* considers z as vertical. Here's a picture for those of you who don't understand pitch, yaw, and roll:<br><br>www.allstar.fiu.edu/aero/images/pic5-1.gif<br><br>I don't know why it returns a Vec3, but sometimes the values x and y go negative, yet they're always zero. Just use GET_ENTITY_PITCH and GET_ENTITY_ROLL for pitch and roll.
{{ClientsideJsFunction}}
{{JSContainer|
 
<pre>
enum eRotationOrder { // Rotation Orders
    XYZ = 0,
    XZY,
    YXZ,
    YZX,
    ZXY,
    ZYX,
    MAX,
}
</pre>
 
 
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">entity.getRotation(rotationOrder);</syntaxhighlight>
<syntaxhighlight lang="javascript">entity.getRotation(rotationOrder);</syntaxhighlight>
=== Required Arguments ===
=== Required Arguments ===
*'''rotationOrder:''' int
*'''rotationOrder:''' {{RageType|Int}} (specifies which axis rotates before the other axis in a certain order)
 
===Return value===
===Return value===
*'''Vector3'''
*'''Vector3'''
==Example==
==Example==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// todo
 
const vehicle = mp.vehicles.at(0);
if (!vehicle || !mp.vehicles.exists(vehicle)) return;
const rotation = vehicle.getRotation(2);
mp.console.logInfo(`Vehicle Rotation: ${JSON.stringify(rotation)}`, false, false);
 
</syntaxhighlight>
</syntaxhighlight>
}}
==See also==
==See also==
{{Entity_function_c}}
{{Entity_definition_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]
[[Category:TODO: Example]]

Latest revision as of 18:03, 1 May 2024

Client-Side
Function

 JavaScript



JavaScript Syntax


enum eRotationOrder { // Rotation Orders
    XYZ = 0,
    XZY,
    YXZ,
    YZX,
    ZXY,
    ZYX,
    MAX,
}


Syntax

entity.getRotation(rotationOrder);

Required Arguments

  • rotationOrder: Int (specifies which axis rotates before the other axis in a certain order)

Return value

  • Vector3

Example

const vehicle = mp.vehicles.at(0);
if (!vehicle || !mp.vehicles.exists(vehicle)) return;
const rotation = vehicle.getRotation(2);
mp.console.logInfo(`Vehicle Rotation: ${JSON.stringify(rotation)}`, false, false);


See also