#**I want to add animation but the game crash.**

7 messages · Page 1 of 1 (latest)

gray kindle
#

Adding animation to my game. But I’m having trouble with it. The game is crashing..
Can anyone help me figure out what I’m doing wrong or link me to an answer for reference? I’ve looked around but couldn’t find anything.

cold stratus
#

This line is the problem: @onready var animated_sprite_2d = AnimatedSprite2D
In your case animated_sprite_2d is not the node in the tree, but the class AnimatedSprite2D.

You need to change it to this for example by adding the $ symbol to get the path of the node : @onready var animated_sprite_2d = $AnimatedSprite2D

gray kindle
#

I did change it to @onready var animated_sprite_2d = $AnimatedSprite2D but it still crashes.

cold stratus
#

same error?

gray kindle
#

This error Invalid assignment of property or key 'flip_h' with value of type 'bool' on a base object of type 'null instance'.

cold stratus
#

Hmm that´s weird, so the reference to the node is wrong then. You didnt rename any node right?
If you drag the node into the editor it should give the right node path and looking at your scenetree the path with the given node name is $AnimatedSprite2D

gray kindle
#

I solved it by adding a script to animationSprite2D and changing the flip_h there and thank you 🙂