Skip to content

Animation Module โ€‹

The Animation module provides utility functions for handling RedM animations, movement, and heading controls.

Getting Started โ€‹

lua
-- Get animation module instance
local Animation = exports.bln_lib:animation()

Constants โ€‹

Animation.easeIn โ€‹

Default ease-in value for animations (4.0)

Animation.easeOut โ€‹

Default ease-out value for animations (-4.0)

Methods โ€‹

Animation.load โ€‹

Load an animation dictionary.

lua
Animation.load(dict, waiter)

Parameters

  • dict (string): Animation dictionary name
  • waiter (boolean): Wait for dictionary to load if true

Example

lua
-- Load animation dictionary without waiting
Animation.load('script@story@mob3@ig@ig1_dutch_holds_up_cashier', false)

-- Load and wait for completion
Animation.load('script@story@mob3@ig@ig1_dutch_holds_up_cashier', true)

Animation.play โ€‹

Play an animation on a specified ped.

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

Parameters

  • ped (integer): Ped handle
  • dict (string): Animation dictionary name
  • name (string): Animation name
  • duration (number, optional): Animation duration in milliseconds (-1 for full duration)
  • flag (integer, optional): Animation flags (0 by default)
  • offset (number, optional): Animation offset (0.0 by default)

Returns

  • number: Animation duration in milliseconds

Example

lua
local ped = PlayerPedId()
local duration = Animation.play(ped, 
    'script@story@mob3@ig@ig1_dutch_holds_up_cashier', 
    'ig1_cashier_idle', 
    -1,    -- Play full animation
    1,     -- Use animation flag 1
    0.0    -- No offset
)

Animation.goToCoords โ€‹

Make a ped move to specified coordinates.

lua
Animation.goToCoords(ped, coords, speed, waiter, distanceToStop)

Parameters

  • ped (integer): Ped handle
  • coords (vector3/vector4): Target coordinates (if vector4, w component is used as final heading)
  • speed (number, optional): Movement speed (1.0 by default)
  • waiter (boolean, optional): Wait for movement to complete
    • Default: true if coords is vector4, false otherwise
  • distanceToStop (number, optional): Distance at which to consider movement complete

Example

lua
local ped = PlayerPedId()

-- Simple movement without waiting
local targetPos = vector3(1234.0, 5678.0, 90.0)
Animation.goToCoords(ped, targetPos)

-- Move with specific speed
Animation.goToCoords(ped, targetPos, 2.0)

-- Move and face specific direction
local targetPosWithHeading = vector4(1234.0, 5678.0, 90.0, 180.0)
Animation.goToCoords(ped, targetPosWithHeading)

-- Move with custom stop distance
Animation.goToCoords(ped, targetPos, 1.0, true, 2.0)

Animation.setDesiredHeading โ€‹

Make a ped face a specific direction.

lua
Animation.setDesiredHeading(ped, heading, waiter)

Parameters

  • ped (integer): Ped handle
  • heading (number): Target heading in degrees (0-360)
  • waiter (boolean, optional): Wait for rotation to complete (true by default)

Example

lua
local ped = PlayerPedId()

-- Turn ped and wait for completion
Animation.setDesiredHeading(ped, 180.0)

-- Turn ped without waiting
Animation.setDesiredHeading(ped, 90.0, false)

Common Animation Flags โ€‹

For the flag parameter in Animation.play:

FlagDescription
0Default
1Looping
2Hold last frame
16Upper body only
32Allow rotation
120Cancelable

Examples โ€‹

Complete Movement Sequence โ€‹

lua
local ped = PlayerPedId()

-- Move to position
local target = vector4(1234.0, 5678.0, 90.0, 180.0)
Animation.goToCoords(ped, target)

-- Play animation
Animation.play(ped, 
    'script@story@mob3@ig@ig1_dutch_holds_up_cashier', 
    'ig1_cashier_idle'
)

-- Turn to specific direction
Animation.setDesiredHeading(ped, 270.0)

Loading and Playing Animation โ€‹

lua
local ped = PlayerPedId()
local dict = 'script@story@mob3@ig@ig1_dutch_holds_up_cashier'

-- Load dictionary first
Animation.load(dict, true)

-- Then play animation
Animation.play(ped, dict, 'ig1_cashier_idle', -1, 1)