GetVehicleRotation

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 15:02, 6 July 2016
AbyssMorgan (Talk | contribs)
(Update note)
← Previous diff
Revision as of 17:31, 6 July 2016
Vince (Talk | contribs)
(pitch, roll, yaw)
Next diff →
Line 6: Line 6:
{{Param|vehicleid|The ID of the vehicle to get the rotation of.}} {{Param|vehicleid|The ID of the vehicle to get the rotation of.}}
-{{Param|&Float:rx|The variable to store the X rotation, passed by reference.}}+{{Param|&Float:rx|The variable to store the X (pitch) rotation, passed by reference.}}
-{{Param|&Float:ry|The variable to store the Y rotation, passed by reference.}}+{{Param|&Float:ry|The variable to store the Y (roll) rotation, passed by reference.}}
-{{Param|&Float:rz|The variable to store the Z rotation, passed by reference.}}+{{Param|&Float:rz|The variable to store the Z (yaw) rotation, passed by reference.}}
{{Returns|The vehicle rotation}} {{Returns|The vehicle rotation}}

Revision as of 17:31, 6 July 2016



Description:

Get the rotation of a vehicle on the XYZ axis.


Parameters:
(vehicleid, &Float:rx, &Float:ry, &Float:rz)


vehicleidThe ID of the vehicle to get the rotation of.
&Float:rxThe variable to store the X (pitch) rotation, passed by reference.
&Float:ryThe variable to store the Y (roll) rotation, passed by reference.
&Float:rzThe variable to store the Z (yaw) rotation, passed by reference.


Return Values:

The vehicle rotation


Image:32px-Ambox_warning_orange.png

Note

  • There is no 'set' variation of this function; you can not SET a vehicle's rotation (apart from the Z angle)
  • To use this function you must define it.
  • This function does not work on unoccupied vehicles.


//GetVehicleRotation Created by IllidanS4
stock GetVehicleRotation(vehicleid,&Float:rx,&Float:ry,&Float:rz){
	new Float:qw,Float:qx,Float:qy,Float:qz;
	GetVehicleRotationQuat(vehicleid,qw,qx,qy,qz);
	rx = asin(2*qy*qz-2*qx*qw);
	ry = -atan2(qx*qz+qy*qw,0.5-qx*qx-qy*qy);
	rz = -atan2(qx*qy+qz*qw,0.5-qx*qx-qz*qz);
}

Related Functions

The following functions may be useful, as they are related to this function in one way or another.