Player::taskPlayAnim: Difference between revisions

From RAGE Multiplayer Wiki
(Tidied up formatting, updated information based on testing. Removed misinformation.)
No edit summary
Line 28: Line 28:
*512: Disables collision and physics on ped
*512: Disables collision and physics on ped
*1024: Disables collision and physics on ped, applies animation initial offset (see [[Ped::getAnimInitialOffsetPosition]] and [[Ped::getAnimInitialOffsetRotation]])
*1024: Disables collision and physics on ped, applies animation initial offset (see [[Ped::getAnimInitialOffsetPosition]] and [[Ped::getAnimInitialOffsetRotation]])
*2048: Disables collision and physics on ped
*2048: Disables collision and physics on ped, take care of the current position/rotation


:''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.
:''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.

Revision as of 16:37, 10 July 2021

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: Normal
  • 1: Repeat/loop
  • 2: Stop animation on last frame
  • 16: Animate upper body only
  • 32: Enable player control (animation is played as a secondary task - can be used to mix animations)
  • 128: Cancellable
  • 256: Additive animation
  • 512: Disables collision and physics on ped
  • 1024: Disables collision and physics on ped, applies animation initial offset (see Ped::getAnimInitialOffsetPosition and Ped::getAnimInitialOffsetRotation)
  • 2048: Disables collision and physics on ped, take care of the current position/rotation
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

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