How do I set an AnimationPlayer node to play on collision?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GasStation

The code in question is

func _on_door_anim_body_entered(body):
if body.name == "Player":
	$door_open_anim.play("EXPAND")

It always gives me an error

Attempt to call function "play" in base "null instance" on a null instance.
:bust_in_silhouette: Reply From: jgodfrey

So, that error means that the $door_open_anim reference isn’t valid. You don’t show how/where that’s set, but it isn’t working.