Player::taskPlayAnim

From RAGE Multiplayer Wiki

Plays an animation on the targetted ped.

You must always preload the dictionary (use Streaming::requestAnimDict to preload an animation), serverside will have some loaded but not all.

Arguments

Animation Dictionary, Animation Name

  • A few possible values can be found on the Animations page.

Blend speed:

  • Defines the blend time before/after the animation. Most common value is 8.
1 / [time in seconds] = [blend speed]

Duration (ms):

  • How long the animation plays. -1 can be used to play the whole animation (or loop indefinitely, if flag 1 is used)

Animation Flags:

  • 0: AF_DEFAULT
  • 1: AF_LOOPING - Repeat the animation
  • 2: AF_HOLD_LAST_FRAME - Hold on the last frame of the animation
  • 4: AF_REPOSITION_WHEN_FINISHED - When the animation finishes pop the peds physical reprsentation position to match the visual representations position Note that the animator must not unwind the animation and must have an independent mover node
  • 8: AF_NOT_INTERRUPTABLE - Can the task not be interupted by extenal events
  • 16: AF_UPPERBODY - Only plays the upper body part of the animation. Dampens any motion caused by the lower body animation.Note that the animation should include the root node
  • 32: AF_SECONDARY - The task will run in the secondary task slot. This means it can be used aswell as a movement task (for instance)
  • 64: AF_REORIENT_WHEN_FINISHED - When the animation finishes pop the peds physical reprsentation direction to match the visual representations direction. Note that the animator must not unwind the animation and must have an independent mover node
  • 128: AF_ABORT_ON_PED_MOVEMENT - Ends the animation early if the ped attemps to move e.g. if the player tries to move using the controller. Can also be used to blend out automatically when an ai ped starts moving by combining it with the AF_SECONDARY flag.
  • 256: AF_ADDITIVE - Play back the animation additively. Note, this will only produce sensible results on specifically authored additive animations!
  • 512: AF_TURN_OFF_COLLISION - Do not react to collision detection whilst this anim is playing
  • 1024: AF_OVERRIDE_PHYSICS - Do not apply any physics forces whilst the anim is playing. Automatically turns off collision, extracts any initial offset provided in the clip and uses per frame mover extraction.
  • 2048: AF_IGNORE_GRAVITY - Do not apply gravity while the anim is playing
  • 4096: AF_EXTRACT_INITIAL_OFFSET - Extract an initial offset from the playback position authored by the animator. Use this flag when playing back anims on different peds which have been authored to sync with each other
  • 8192: AF_EXIT_AFTER_INTERRUPTED - Exit the animation task if it is interrupted by another task (ie Natural Motion). Without this flag bing set looped animations will restart ofter the NM task

Tag synchronizer flags - sync the anim against ped movement (walking / running / etc):

  • 16384: AF_TAG_SYNC_IN - Sync the anim whilst blending in (use for seamless transitions from walk / run into a full body anim)
  • 32768: AF_TAG_SYNC_OUT - Sync the anim whilst blending out (use for seamless transitions from a full body anim into walking / running behaviour)
  • 65536: AF_TAG_SYNC_CONTINUOUS - Sync all the time (Only usefull to synchronize a partial anim e.g. an upper body)
  • 131072: AF_FORCE_START - Force the anim task to start even if the ped is falling / ragdolling / etc. Can fix issues with peds not playing their anims immediately after a warp / etc
  • 262144: AF_USE_KINEMATIC_PHYSICS - Use the kinematic physics mode on the entity for the duration of the anim (it should push other entities out of the way, and not be pushed around by players / etc
  • 524288: AF_USE_MOVER_EXTRACTION - Updates the peds capsule position every frame based on the animation. Use in conjunction with AF_USE_KINEMATIC_PHYSICS to create characters that cannot be pushed off course by other entities / geometry / etc whilst playing the anim.
  • 1048576: AF_HIDE_WEAPON - Indicates that the ped's weapon should be hidden while this animation is playing.
  • 2097152: AF_ENDS_IN_DEAD_POSE - When the anim ends, kill the ped and use the currently playing anim as the dead pose
  • 4194304: AF_ACTIVATE_RAGDOLL_ON_COLLISION - If the peds ragdoll bounds make contact with something physical (that isn't flat ground) activate the ragdoll and fall over.
  • 8388608: AF_DONT_EXIT_ON_DEATH - Currently used only on secondary anim tasks. Secondary anim tasks will end automatically when the ped dies. Setting this flag stops that from happening."
  • 16777216: AF_ABORT_ON_WEAPON_DAMAGE - Allow aborting from damage events (including non-ragdoll damage events) even when blocking other ai events using AF_NOT_INTERRUPTABLE.
  • 33554432: AF_DISABLE_FORCED_PHYSICS_UPDATE - Prevent adjusting the capsule on the enter state (useful if script is doing a sequence of scripted anims and they are known to more or less stand still)
  • 67108864: AF_PROCESS_ATTACHMENTS_ON_START - Force the attachments to be processed at the start of the clip
  • 134217728: AF_EXPAND_PED_CAPSULE_FROM_SKELETON - Expands the capsule to the extents of the skeleton
  • 268435456: AF_USE_ALTERNATIVE_FP_ANIM - Plays an alternative first person version of the clip on the player when in first person mode (the first person clip must be in the same dictionary, and be named the same as the anim you're playing, but with _FP appended on the end)
  • 536870912: AF_BLENDOUT_WRT_LAST_FRAME - Start blending out the anim early, so that the blend out duration completes at the end of the animation.
  • 1073741824 AF_USE_FULL_BLENDING - Use full blending for this anim and override the heading/position adjustment in CTaskScriptedAnimation::CheckIfClonePlayerNeedsHeadingPositionAdjust(), so that we don't correct errors (special case such as scrip-side implemented AI tasks, i.e. diving)
Note: You can sum flags together. For example, if you want an upper body controllable animation with last frame you can do 48+2 which is flag 50.

Start Offset:

  • Can be used to skip a part of the animation. Values are between 0.0 and 1.0 (doesn't seem to work, use mp.game.entity.setAnimCurrentTime instead)


Syntax

player.taskPlayAnim(animDictionary, animationName, blendInSpeed, blendOutSpeed, duration, flag, startOffset, lockX, lockY, lockZ);

Required Arguments

  • animDictionary: String
  • animationName: String
  • blendInSpeed: float
  • blendOutSpeed: float
  • duration: int
  • flag: int
  • startOffset: float
  • lockX: Boolean
  • lockY: Boolean
  • lockZ: Boolean

Return value

  • Undefined

Example

The example below preloads an animation and applies it into the local player.

mp.game.streaming.requestAnimDict("random@shop_robbery");//preload the animation
mp.players.local.taskPlayAnim("random@shop_robbery", "robbery_action_f", 8.0, 1.0, -1, 1, 1.0, false, false, false);

See also