Menu
CoddyTech

Play It Backwards

Part of the Game Feel section of Coddy's Godot journey. Lesson 23 of 23.

The door has one animation, "open". The panel slides up and the light turns from coral to mint. Closing is the same motion in reverse, so you do not need a second animation.

$AnimationPlayer.play_backwards("open")

play_backwards plays an animation from its last key to its first. The panel slides back down and the light turns coral again.

Playing "open" forward would not close the door. It would start again from the first key, closed, and slide open.

challenge icon

Challenge

Easy

Make E close the door when it is open.

  1. Find the if is_open: branch.
  2. Replace its pass: play "open" backwards on $AnimationPlayer.

Press Play and press E twice: the door slides open, then shut. Then Check.

Try it yourself

extends Node2D

var is_open = false

func _process(delta):
	if Input.is_action_just_pressed("action"):
		if is_open:
			pass
		else:
			$AnimationPlayer.play("open")
		is_open = not is_open
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Game Feel

Practice on your own: Godot playground