Repository navigation
09. Binding playback events
There comes times when adding animations is not enough to implement certain features of a game, and a more granular control of the playback is required. Because of this, multiple ways of managing the playback of the animations are present, to enable users to accomplish their goals as easily as possible.
As shown before, Playback rate can be managed in a “per-node” instance on the Animation Graph.

With this one could implement climbing ladder animations depending if the character is moving or not, like old platformers, by pausing the animation when not moving or even reversing it when going down the ladder.
Sometimes though, more global control is needed, and adding a variable on every Play Node wouldn’t be scalable enough, in these situations it’s more sensible to directly interface with the AnimPlayer.
PaperZD’s playback control is centralized via a central object that works as the Playback manager which ticks animation nodes, triggers notifies and calls events pertaining to the state of the animation sequences being run. You can access this object by simply calling the following node:

This object comes with a set of interesting callbacks and events for managing the global state of the playback of animations.

Using this object, you can easily pause the playback, change the playback mode (forward or reversed) and query the current state of rendering (knowing the time of the current animation, which animation is playing, etc).
ℹ️ Note: Certain calls like the current animation or animation time, only take into account the biggest weighted animation on the mix. This is only important on skeleton and blending enabled animation sources, as those can mix multiple animations into a final blend.
The AnimPlayer also comes with a set of events that get automatically called during playback:

Two of these are already implemented by the AnimationInstance and can be overridden directly:
Playback Complete

These events (specifically Playback Complete) are how the Transitional Graphs detect that the transitional animation has finished its playback. You can bind or implement them to be notified when the rendering of an animation changes.