GetElementBoneRotation: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
{{New feature/item|3.0159|1.5.8|20704|Returns the orientation of a specific bone relative to the [[element]]. Currently the following element types are accepted:
Returns the orientation of a specific bone relative to the [[element]]. Currently the [[Element/Player|Player]] and [[Element/Ped|Ped]] element types are accepted.
* [[Element/Player|Player]]
 
* [[Element/Ped|Ped]]
{{Tip|If you want to attach an element to a bone, see [[attachElementToBone]].}}
}}
{{Tip|If you want to attach an element to a bone, see [[attachElementToBone]]}}


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
float, float, float getElementBoneRotation ( element theElement, int bone )
float, float, float getElementBoneRotation ( element theElement, int boneId )
</syntaxhighlight>
</syntaxhighlight>


Line 15: Line 13:


===Required Arguments===
===Required Arguments===
*'''theElement:''' the element to get the bone rotation on.
*'''theElement:''' the [[element]] to get the bone rotation on.
*'''bone:''' the ID of the bone to get the rotation of. See [[Bone IDs]]
*'''boneId:''' the ID of the bone to get the rotation of. See [[Bone IDs]].


===Returns===
===Returns===
Returns the yaw, pitch, roll rotation values.
Returns 3 [[Float|floats]], representing the yaw, pitch, roll rotation values.


==Example==
==Example==
{{Needs Example}}
This example outputs the yaw, pitch and roll orientation of a specific bone relative to the local player bone specified through a command:
<syntaxhighlight lang="lua">
function getBoneRotation (commandName, boneId)
    if not tonumber (boneId) then
        outputChatBox ("You didn't insert an bone ID!", 255, 0, 0)
        return false
    end
 
    local x, y, z = getElementBoneRotation (localPlayer, boneId)
    outputChatBox ("The bone rotation is: "..x..", "..y..", "..z)
end
 
addCommandHandler ("getbonerotation", getBoneRotation)
</syntaxhighlight>
 
==Requirements==
{{Requirements|n/a|1.5.8-9.20704|}}


==See Also==
==See Also==
{{Client_element_functions}}
{{Client_element_functions}}

Revision as of 15:06, 19 September 2021

Returns the orientation of a specific bone relative to the element. Currently the Player and Ped element types are accepted.


[[{{{image}}}|link=|]] Tip: If you want to attach an element to a bone, see attachElementToBone.

Syntax

float, float, float getElementBoneRotation ( element theElement, int boneId )
Rotation axes

Required Arguments

  • theElement: the element to get the bone rotation on.
  • boneId: the ID of the bone to get the rotation of. See Bone IDs.

Returns

Returns 3 floats, representing the yaw, pitch, roll rotation values.

Example

This example outputs the yaw, pitch and roll orientation of a specific bone relative to the local player bone specified through a command:

function getBoneRotation (commandName, boneId)
    if not tonumber (boneId) then
        outputChatBox ("You didn't insert an bone ID!", 255, 0, 0)
        return false
    end

    local x, y, z = getElementBoneRotation (localPlayer, boneId)
    outputChatBox ("The bone rotation is: "..x..", "..y..", "..z)
end

addCommandHandler ("getbonerotation", getBoneRotation)

Requirements

This template will be deleted.

See Also