Skip to content

animations

The animations namespace manages stateful numeric transitions keyed by unique identifiers. Values persist across frames without manual state tracking.


local anim = animations.new(name: string, start_value?: number) --> animation_t

Retrieves or creates a named animation instance.

local current_val = anim:update(type: number, target: number, speed?: number, min?: number) --> number

Updates and returns the new value towards target.

  • type: Interpolation curve type from animations.types.*.
  • speed: Transition speed coefficient (defaults to 0.095, automatically scaled by frametime).
  • min: Arrival epsilon threshold (defaults to 1.0).
local val = anim:get() --> number
anim:set(value: number) --> nil
animations.reset()

Clears all stored animation states in memory.


  • animations.types.LERP
  • animations.types.SINE3
  • animations.types.IN_SINE, OUT_SINE, IN_OUT_SINE
  • animations.types.IN_CUBIC, OUT_CUBIC, IN_OUT_CUBIC
  • animations.types.IN_QUINT, OUT_QUINT, IN_OUT_QUINT
  • animations.types.IN_CIRC, OUT_CIRC, IN_OUT_CIRC

client.add_callback("render", function()
local me = entity.get_local_player()
if not me then return end
local center = render.screen_size() / 2
local target_offset = me.m_bIsScoped and 40 or 0
-- Create and update persistent animation named 'scope_offset'
local anim_offset = animations.new("scope_offset", 0)
:update(animations.types.OUT_CUBIC, target_offset, 0.15)
render.text(2, vector(center.x + anim_offset, center.y), color(255, 255, 255), "c", "INDICATOR")
end)