Scripting: Animation Flags
In GTA 5, animations use flags to control certain aspects of the animation playback. These flags modify the behavior of the animation and provide additional functionality.
The native function to use for animating the player or an NPC is: TASK_PLAY_ANIM.
The complete function: void TASK_PLAY_ANIM(Ped ped, const char* animDictionary, const char* animationName, float blendInSpeed, float blendOutSpeed, int duration, int flag, float playbackRate, BOOL lockX, BOOL lockY, BOOL lockZ) // 0xEA47FE3719165B94 0x5AB552C6 b323
Here are some commonly used animation flags:
ANIM_FLAG_NORMAL = 0, ANIM_FLAG_REPEAT = 1, ANIM_FLAG_STOP_LAST_FRAME = 2, ANIM_FLAG_UPPERBODY = 16, ANIM_FLAG_ENABLE_PLAYER_CONTROL = 32, ANIM_FLAG_CANCELABLE = 120,
Loop: This flag makes the animation play repeatedly in a loop until stopped manually. It is useful for continuous animations like walking or running.
StopLastFrame: When this flag is used, the animation playback stops on the last frame of the animation instead of looping. It is often used for one-time animations like opening a door or performing a specific action.
OnlyAnimateUpperBody: This flag restricts the animation to the upper body, allowing the character to perform actions without moving their legs. It is useful for activities like shooting, interacting with objects, or using tools.
Cancellable: When this flag is set, the animation can be interrupted or cancelled by certain actions such as combat or other interactive interactions. It gives the player more flexibility to control the character's actions during the animation.
WaitOnCompletion: By using this flag, the game waits for the animation to complete before executing the next script line. It ensures that the animation finishes before proceeding with the following actions.
UpperBodyOnly: This flag limits the animation to affect only the upper body parts of the character, excluding the legs and lower body. It is useful for animations involving upper body movements like arm gestures or animations for speaking.
AllowPlayerControl: This flag allows the player to retain control over the character during the animation playback. It enables the player to move or perform other actions concurrently with the animation.
These animation flags provide flexibility and control over the playback behavior of animations in GTA 5, allowing developers to create dynamic and interactive character movements within the game.