Godot 3 Tutorial– Keyframe Animation

This video covers 2D keyframe animation in Godot.  In Godot 3.1, the animation system got a massive overhaul, making it easy to create complex animations using keyframes.  This video showcases how to use AnimationPlayer, AnimationTreePlayer, and the animation system, in general, to create and blend animations in Godot.

The Video

Code Samples

KeyframeAnimation.gd

extends Node2D

var counter = 0
func _process(delta):
	if Input.is_key_pressed(KEY_B):
		if $AnimationPlayer.is_playing() == false:
			$AnimationPlayer.play("bounce")
			print("Bouncing")		
			
	if Input.is_action_just_released("one"):
		$AnimationTreePlayer.active = true
		var val = $AnimationTreePlayer.blend2_node_get_amount("blend2")
		if(val >= 0.1):
			$AnimationTreePlayer.blend2_node_set_amount("blend2",val -0.1)
			
	if Input.is_action_just_released("two"):
		$AnimationTreePlayer.active = true
		var val = $AnimationTreePlayer.blend2_node_get_amount("blend2")
		if(val <= 1):
			$AnimationTreePlayer.blend2_node_set_amount("blend2",val + 0.1)
			
	counter += delta
	if counter >0.1:
		if $AnimationPlayer.is_playing():
			print("Cur anim time remaining " + str($AnimationPlayer.current_animation_length - $AnimationPlayer.current_animation_position))
			counter = 0

Back to Tutorial Series Homepage

Scroll to Top