SetElementRotation: Difference between revisions
Jump to navigation
Jump to search
Line 20: | Line 20: | ||
*'''rotOrder:''' A string representing the rotation order desired when interpreting the provided [http://en.wikipedia.org/wiki/Euler_angles euler angles]. If omitted, default value is ''"default"''. Allowed values are: | *'''rotOrder:''' A string representing the rotation order desired when interpreting the provided [http://en.wikipedia.org/wiki/Euler_angles euler angles]. If omitted, default value is ''"default"''. Allowed values are: | ||
**''"default":'' default MTA behavior prior to 1.1, where rotation order depends on element type | **''"default":'' default MTA behavior prior to 1.1, where rotation order depends on element type | ||
**''"ZXY":'' rotation about the Z axis (''up''), then about the resulting X axis (''right'') and finally about the resulting Y axis (''front''). This is the default rotation order for [[object|objects]] | **''"ZXY":'' rotation about the Z axis (''up''), then about the resulting X axis (''right''), and finally about the resulting Y axis (''front''). This is the default rotation order for [[object|objects]] | ||
**''"ZYX":'' rotation about the Z axis (''up''), then about the resulting Y axis (''front''), and finally about the resulting X axis (''right'') | **''"ZYX":'' rotation about the Z axis (''up''), then about the resulting Y axis (''front''), and finally about the resulting X axis (''right''). This is the default rotation order for [[vehicle|vehicles]] | ||
The default rotation order for peds/players is -Z-Y-X but this rotation order (set using ''"default"'' on peds) can not be set manually on other element types since it only exists due to historical and backward compatibility reasons. | The default rotation order for peds/players is -Z-Y-X but this rotation order (set using ''"default"'' on peds) can not be set manually on other element types since it only exists due to historical and backward compatibility reasons. |
Revision as of 19:32, 9 November 2010
Sets the rotation of elements according to the world (does not work with players that are on the ground).
Only clientside before 1.0.4
Syntax
bool setElementRotation ( element theElement, float rotX, float rotY, float rotZ [, string rotOrder])
Required Arguments
- theElement: The element whose rotation will be set
- rotX: The element's rotation around the x axis in degrees
- rotY: The element's rotation around the y axis in degrees
- rotZ: The element's rotation around the z axis in degrees
Optional Arguments
Returns
Returns true if the element rotation was successfully set and false otherwise.
Example
When a player used the command "turn" and they are the driver of a vehicle the vehicle will rotate 10 degrees clockwise
Click to collapse [-]
Clientlocal localPlayer = getLocalPlayer() function carRotate( ) if isPedInVehicle(localPlayer) then -- if the local client is in a vehicle localVehicle = getPedOccupiedVehicle(localPlayer) if getVehicleController(localVehicle) == localPlayer then -- if the local client is the controller (driver) of the vehicle local rotX, rotY, rotZ = getElementRotation(localVehicle) -- get the local client's vehicle rotation setElementRotation(localVehicle,rotX,rotY,rotZ+10) -- turn the vehicle 10 degrees clockwise end end end addCommandHandler ( "turn", carRotate )
See Also
- getElementBoneMatrix
- getElementBonePosition
- getElementBoneRotation
- getElementBoundingBox
- getElementDistanceFromCentreOfMassToBaseOfModel
- getElementLighting
- getElementRadius
- isElementCollidableWith
- isElementLocal
- isElementOnScreen
- isElementStreamable
- isElementStreamedIn
- isElementSyncer
- isElementWaitingForGroundToLoad
- setElementBoneMatrix
- setElementBonePosition
- setElementBoneRotation
- setElementCollidableWith
- setElementStreamable
- updateElementRpHAnim
- Shared
- attachElements
- createElement
- destroyElement
- detachElements
- getAttachedElements
- getElementAlpha
- getElementAttachedOffsets
- getElementAttachedTo
- getElementByIndex
- getElementByID
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getAllElementData
- hasElementData
- getElementDimension
- getElementHealth
- getElementID
- getElementInterior
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementType
- getElementVelocity
- getLowLODElement
- getRootElement
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLowLOD
- isElementWithinColShape
- isElementWithinMarker
- setElementAlpha
- setElementAngularVelocity
- getElementAngularVelocity
- setElementAttachedOffsets
- setElementCallPropagationEnabled
- setElementCollisionsEnabled
- setElementData
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementModel
- setElementParent
- setElementPosition
- setElementRotation
- setElementVelocity
- setLowLODElement
- getPedContactElement
- getResourceDynamicElementRoot
- getResourceRootElement