mvbg

VM_ACTOR_SET_ANIM_TICK

VM_ACTOR_SET_ANIM_TICK is a GBVM instruction used to control the speed or frame rate of an actor’s animation.

Purpose: Animations in games are typically played back at a certain speed, often measured in “ticks” or frames per animation frame. VM_ACTOR_SET_ANIM_TICK allows you to adjust this playback speed for individual actors. This is essential for:

When VM_ACTOR_SET_ANIM_TICK is called, it sets the number of game frames (or internal ticks) that must pass before the actor’s animation advances to the next frame. A higher TICK value means a slower animation, and a lower TICK value means a faster animation.

Syntax:

VM_ACTOR_SET_ANIM_TICK ACTOR, TICK

Usage Example: Slowing Down an Enemy’s Movement Animation

Imagine you have a large, slow-moving enemy. You want its walking animation to reflect its slow pace, playing back at a slower rate than other characters.

; In your enemy's initialization script or update loop:

; Assume ENEMY_GIANT_SLUG is the actor ID for the slow enemy
ENEMY_GIANT_SLUG:
  .R_INT8 40 ; Example Actor ID

; Set the animation tick for the giant slug to make its animation slower
; A value of 4 means the animation frame changes every 4 game frames.
VM_ACTOR_SET_ANIM_TICK ENEMY_GIANT_SLUG, 4

; Set its walking animation
VM_ACTOR_SET_ANIM ENEMY_GIANT_SLUG, ANIM_SLUG_WALK

; ... rest of enemy AI and movement logic ...

; Example of a fast-moving character:
PLAYER_ACTOR_ID:
  .R_INT8 0
VM_ACTOR_SET_ANIM_TICK PLAYER_ACTOR_ID, 1 ; Player animation updates every frame (fastest)
VM_ACTOR_SET_ANIM PLAYER_ACTOR_ID, ANIM_PLAYER_WALK

In this example, VM_ACTOR_SET_ANIM_TICK ENEMY_GIANT_SLUG, 4 makes the ENEMY_GIANT_SLUG’s animation play at one-fourth the speed of a normal animation (assuming a default tick of 1). This visually reinforces its slow nature. The player, on the other hand, might have their animation set to 1 for a fluid, fast walk.

Analogy to other programming languages/game engines: This is analogous to setting the animation speed, playback rate, or frame delay for an animation clip or sprite animation in a game engine:

It provides fine-grained control over the temporal aspect of an actor’s visual animations.