SingleAnimationPlayer

This component is just a helper that performs actual animation sampling. You can write your own component with more complex logic if needed.

Classes

SingleAnimationPlayer : Component

Note

Animator component is automatically added to the node if it is not already present

This component perform playing specified animation There is no blending between animations

Fields:
  • enabled : bool = true - If this is false, the animation will not be sampled and played. Can be used to pause the animation.

  • loop : bool = true - If this is true, the animation will loop. If this is false, the animation will play once and stop.

  • animation : AnimationId - The animation to play

  • speed : float = 1f - The speed at which to play the animation. All values are allowed, but negatives values are nor recommended in sence of performance. Zero value also not recommended, better to set enable to false.

  • progress : float = 0f - This is the progress of the animation in the range [0, 1]. If it outside of this range, it will be clamped.

SingleAnimationPlayer.on_update()

Perform very simple logic of sampling one animation with specified speed and progress. The logic is as follows

get_animation_duration(animation) $(duration : float) {
    let dt = get_delta_time()
    progress += dt * safediv(speed, duration)
    if (loop) {
        progress -= float(int(progress))
    }
    sample_animation_and_blend(nodeId, [animation], [progress], [1f])
}