Skip to content

Animation Client

Animation is a powerfull module to play animations in your script.

JO Variables

jo.animation.easeIn

Type : float:

A variable to set the ease in speed of animations
Default: 4.0

jo.animation.easeOut

Type : float

A variable to set the ease out speed of animations
Default: -4.0

JO Functions

jo.animation.faceEntity()

Turn the ped to face the target

Syntax

lua
jo.animation.faceEntity(ped, target, waiter)

Parameters

ped : integer

The ped to turn

target : integer

The target to face

waiter : boolean Optional

If need to reach the heading to end the function - default:true

Example

lua
local ped = PlayerPedId()
local targetSource = 5
local targetEntity = GetPlayerPed(GetPlayerFromServerId(targetSource))
local waiter = true
jo.animation.faceEntity(ped, targetSource, targetEntity, waiter)

jo.animation.goToCoords()

Function to move a ped to a destination

Syntax

lua
jo.animation.goToCoords(ped, coords, speed, waiter, distanceToStop)

Parameters

ped : integer

The ped to move

coords : vector

vec3 or vec4 - The coordinate of the destination
If vector4 is used, the ped will stop at the end and turn to the desired heading

speed : number Optional

The speed of the walk - default:1.0

waiter : boolean Optional

If need to wait the reach of location to end the function - default:false

distanceToStop : number Optional

The distance between the ped and the destination to stop it - default:0.0

Example

lua
local ped = PlayerPedId()
local destination = vec4(1324.0, 234.0, 50.0, 180.0)
local speed = 2.0
local waiter = true
local distanceToStop = 3.0
jo.animation.goToCoords(ped, destination, speed, waiter, distanceToStop)

jo.animation.load()

Load the dictionnary of animation

Syntax

lua
jo.animation.load(dict, waiter)

Parameters

dict : string

The dictionnary of the animation

waiter : boolean Optional

If need to wait the loading to end the function - default:false

Example

lua
local dict = "cnv_camp@rchso@cnv@ccdtc33@player_karen"
local waiter = true
jo.animation.load(dict, waiter)

jo.animation.play()

Play animation. The function load automatically necessary resources.

Flags list
Bit indexInteger valueNameDescription
01AF_LOOPINGLoop the animation continuously
12AF_HOLD_LAST_FRAMEFreeze on the last frame when done
24AF_NOT_INTERRUPTABLEPrevent other tasks from cancelling the animation
38AF_UPPERBODYPlay on upper body only (allows movement)
416AF_SECONDARYPlay as a secondary/blended animation
532AF_ABORT_ON_PED_MOVEMENTStop the animation when the ped moves
664AF_ADDITIVEBlend additively on top of existing animations
7128AF_OVERRIDE_PHYSICSOverride physics during playback
8256AF_EXTRACT_INITIAL_OFFSETUse the animation's initial position offset
9512AF_EXIT_AFTER_INTERRUPTEDExit cleanly when interrupted
101024AF_TAG_SYNC_INSync entry tag with other peds
112048AF_TAG_SYNC_OUTSync exit tag with other peds
124096AF_TAG_SYNC_CONTINUOUSContinuously sync tag with other peds
138192AF_FORCE_STARTForce the animation to start immediately
1416384AF_USE_KINEMATIC_PHYSICSUse kinematic physics during playback
1532768AF_USE_MOVER_EXTRACTIONExtract movement from the animation clip
1665536AF_DONT_SUPPRESS_LOCODon't suppress locomotion during playback
17131072AF_ENDS_IN_DEAD_POSEHold the final dead pose at the end
18262144AF_ACTIVATE_RAGDOLL_ON_COLLISIONTrigger ragdoll on collision
19524288AF_DONT_EXIT_ON_DEATHKeep playing the animation after death
201048576AF_ABORT_ON_WEAPON_DAMAGECancel the animation when the ped takes weapon damage
212097152AF_DISABLE_FORCED_PHYSICS_UPDATEDisable forced physics updates during playback
224194304AF_GESTUREPlay as a gesture (short, non-blocking)
238388608AF_SKIP_IF_BLOCKED_BY_HIGHER_PRIORITY_TASKSkip if a higher-priority task is active
2416777216AF_USE_ABSOLUTE_MOVERUse absolute world-space movement extraction
2533554432AF_0xC57F16E7Unknown
2667108864AF_UPPERBODY_TAGSApply upper body sync tags
27134217728AF_PROCESS_ATTACHMENTS_ON_STARTProcess ped attachments at animation start
28268435456AF_EXPAND_PED_CAPSULE_FROM_SKELETONExpand the ped's collision capsule based on skeleton
29536870912AF_BLENDOUT_WRT_LAST_FRAMEBlend out relative to the last frame position
301073741824AF_DISABLE_PHYSICAL_ACTIVATIONDisable physical activation events
312147483648AF_DISABLE_RELEASE_EVENTSDisable release/end events for the animation

Syntax

lua
jo.animation.play(ped, dict, name, duration, flag, offset)

Parameters

ped : integer

The entity where the animation will be played

dict : string

The dictionnary of the animation

name : string

The name of the animation

duration : integer Optional

Duration of the animation in ms - default:-1

flag : integer|table Optional

Animation flags - default:0. Pass an integer value or a table of bit indices (e.g.

offset : number Optional

The offset of the animation 0.0 <> 1.0 - default: 0.0

Return Value

Type : number

Example

lua
local ped = PlayerPedId()
local dict = "cnv_camp@rchso@cnv@ccdtc33@player_karen"
local name = "arthur_dance_loop"
local duration = -1
local flag = 1
jo.animation.play(ped, dict, name, duration, flag)

jo.animation.setDesiredHeading()

Turn the ped to the desired heading

Syntax

lua
jo.animation.setDesiredHeading(ped, heading, waiter)

Parameters

ped : integer

The ped to turn

heading : number

The desired heading

waiter : boolean Optional

If need to reach the heading to end the function - default:true

Example

lua
local ped = PlayerPedId()
local heading = 180.0
local waiter = true
jo.animation.setDesiredHeading(ped, heading, waiter)

jo.animation.waitTaskEnd()

Syntax

lua
jo.animation.waitTaskEnd(ped, task)

Example

lua
local ped = PlayerPedId()
local coordinates = vec3(1324.0, 234.0, 50.0)
local speed = 1.0
local maxTime = -1
local radiusEnd = 2.0
local flags = 2 -- Slide at end
local finalHeading = 180.0
TaskFollowNavMeshToCoord(ped, coordinates, speed, maxTime, radiusEnd, flags, finalHeading)
local task = `SCRIPT_TASK_FOLLOW_NAV_MESH_TO_COORD`
jo.animation.waitTaskEnd(ped, task)
print('Task ended. Player reached the coordinates')

Last updated: