SetElementBonePosition: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
Fernando187 (talk | contribs) (Remove obsolete Requirements section) |
||
(21 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | {{Client function}} | ||
{{ | {{Added feature/item|1.5.9|1.5.8|20704|This function sets the position of a bone to the specified coordinates. Currently the [[Element/Player|Player]] and [[Element/Ped|Ped]] element types are accepted.}} | ||
{{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]]}} | |||
{{Note|You need to use this function together with [[onClientPedsProcessed]].}} | {{Note|You need to use this function together with [[onClientPedsProcessed]].}} | ||
Line 14: | Line 11: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theElement:''' the element to set the bone position on. | *'''theElement:''' the [[Element|element]] to set the bone position on. | ||
*'''bone:''' the ID of the bone to set the position of. See [[Bone IDs]] | *'''bone:''' the ID of the bone to set the position of. See [[Bone IDs]]. | ||
*'''x:''' The | *'''x:''' The X coordinate of the destination. | ||
*'''y:''' The | *'''y:''' The Y coordinate of the destination. | ||
*'''z:''' The | *'''z:''' The Z coordinate of the destination. | ||
===Returns=== | ===Returns=== | ||
Line 24: | Line 21: | ||
==Example== | ==Example== | ||
This example | [[File:CJ with long neck.png|thumb|alt=CJ with long neck|Example preview]] | ||
This example shows a surprised CJ with a long neck | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local bones = { | |||
[4] = Vector3(0, 0, 0.15), | |||
[5] = Vector3(0, 0, 0.15), | |||
[6] = Vector3(0, 0, 0.13), | |||
[7] = Vector3(0, 0, 0.13), | |||
[8] = Vector3(0, 0, 0.1), | |||
} | |||
function updatePed() | |||
for bone,v in pairs(bones) do | |||
local pos = localPlayer:getBonePosition(bone)+v | |||
setElementBonePosition(localPlayer, bone, pos) | |||
end | end | ||
end | end | ||
addEventHandler("onClientPedsProcessed", root, updatePed) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Client_element_functions}} | {{Client_element_functions}} |
Latest revision as of 17:23, 7 November 2024
This function sets the position of a bone to the specified coordinates. Currently the Player and Ped element types are accepted.
Tip: If you want to attach an element to a bone, see attachElementToBone. |
Syntax
bool setElementBonePosition ( element theElement, int bone, float x, float y, float z )
Required Arguments
- theElement: the element to set the bone position on.
- bone: the ID of the bone to set the position of. See Bone IDs.
- x: The X coordinate of the destination.
- y: The Y coordinate of the destination.
- z: The Z coordinate of the destination.
Returns
Returns true if the function was successful, false otherwise.
Example
This example shows a surprised CJ with a long neck
local bones = { [4] = Vector3(0, 0, 0.15), [5] = Vector3(0, 0, 0.15), [6] = Vector3(0, 0, 0.13), [7] = Vector3(0, 0, 0.13), [8] = Vector3(0, 0, 0.1), } function updatePed() for bone,v in pairs(bones) do local pos = localPlayer:getBonePosition(bone)+v setElementBonePosition(localPlayer, bone, pos) end end addEventHandler("onClientPedsProcessed", root, updatePed)
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