SetIkTarget
DocsSetIkTarget(ped, ikIndex, entityLookAt, boneLookAt, offsetX, offsetY, offsetZ, ikTargetFlags, blendInDuration, blendOutDuration)Description
Sets the IK target for a given IK part belonging to the ped.
Please note: The IK target will only be valid for one update, so it needs to be set for as long as it is needed (to avoid IK targets not being cleared and getting stuck enabled).
enum eIkPart {
IK_PART_INVALID = 0,
// head
IK_PART_HEAD = 1,
// spine
IK_PART_SPINE = 2,
// Left Arm
IK_PART_ARM_LEFT = 3,
// Right Arm
IK_PART_ARM_RIGHT = 4,
// Left Leg
IK_PART_LEG_LEFT = 5,
// Right Leg
IK_PART_LEG_RIGHT = 6
};enum eIkTargetFlags {
ITF_DEFAULT = 0,
// arm target relative to the handbone
ITF_ARM_TARGET_WRT_HANDBON = 1,
// arm target relative to the pointhelper
ITF_ARM_TARGET_WRT_POINTHELPER = 2,
// arm target relative to the ikhelper
ITF_ARM_TARGET_WRT_IKHELPE = 4,
// use animation tags directly
ITF_IK_TAG_MODE_NORMAL = 8,
// use animation tags in ALLOW mode
ITF_IK_TAG_MODE_ALLOW = 16,
// use animation tags in BLOCK mode
ITF_IK_TAG_MODE_BLOCK = 32,
// solve for orientation in addition to position
ITF_ARM_USE_ORIENTATION = 64
};NativeDB Introduced: v323
Parameters
| Name | Type | Description |
|---|---|---|
ped | Ped | The ped handle. |
ikIndex | int | See `eIkPart` for indexes. |
entityLookAt | Entity | Set to 0 for no entity, offsets will be world coordinates instead. |
boneLookAt | int | Set to -1 for no target bone. |
offsetX | float | X-axis offset calculated from the position of `entityLookAt`. |
offsetY | float | Y-axis offset calculated from the position of `entityLookAt`. |
offsetZ | float | Z-axis offset calculated from the position of `entityLookAt`. |
ikTargetFlags | int | See `eIkTargetFlags` for flags. |
blendInDuration | int | Animation blending in (in ms). `-1` by default. |
blendOutDuration | int | Animation blending out (in ms). `-1` by default. |
Quick Snippet: Get CoordinatesoffsetXoffsetYoffsetZ
offsetXoffsetYoffsetZAdd this command to your client script to retrieve precise locations in-game.
-- Add this to your client.lua. Type /pos in-game to copy coords.
RegisterCommand('pos', function()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)
local output = string.format("vector4(%.2f, %.2f, %.2f, %.2f)", coords.x, coords.y, coords.z, heading)
print(output)
TriggerEvent('chat:addMessage', { args = { '^4[COORD]^0', output } })
end)Quick Snippet: Get Ped Handleped
pedUse this to get the player ped handle for this native.
-- Get the player's ped handle (client-side)
local ped = PlayerPedId()
print("Ped handle: " .. ped)
-- For a specific player's ped (server-side):
-- local targetPed = GetPlayerPed(source)Quick Snippet: Get EntityentityLookAt
entityLookAtUse this to obtain an entity handle from the player's aim or crosshair.
-- Get the entity the player is aiming at
local ped = PlayerPedId()
local hit, entity = GetEntityPlayerIsFreeAimingAt(PlayerId())
if hit and entity ~= 0 then
print("Entity: " .. entity)
print("Model: " .. GetEntityModel(entity))
print("Type: " .. GetEntityType(entity)) -- 1=Ped, 2=Vehicle, 3=Object
endPed Models

mp_m_freemode_01
player_zero
ig_agatha
s_m_y_cop_01
s_m_m_gaffer_01
g_m_m_armboss_01
a_c_boar
a_m_m_bevhills_01Returns
voidThis native does not return a value.
Examples
Official
-- Points the right arm to -1849.0, -1231.0, 13.0 for 10 seconds
SetIkTarget(PlayerPedId(), 4, 0, 0, -1849.0, -1231.0, 13.0, 0, 0, 10000)