Animation not setting on signal

Godot Version

v4.3.stable.official [77dcf97d8]

Question

`Hello there,
new dev here.
Im trying to change an animation on receiving a signal. Heres my code for connecting to the signal and my attempt on changing the animation and a label text:

extends Control

@onready var animated_sprite_2d: AnimatedSprite2D = $ColorRect/ColorRect/AnimatedSprite2D
@onready var effect_label_rect: ColorRect = $EffectLabelRect
@onready var effect_label: Label = $EffectLabelRect/EffectLabel

func _ready() -> void:
	Global.effects_updated.connect(_on_effects_updated)
	_on_effects_updated
	#animated_sprite_2d.animation = "Defense"	#works

func _on_effects_updated():
	print("Effects updated in Effect Box called")
	var index = -1
	index = Global.active_effects.find("Defense")

	if index != -1:
		print(name)
		print("Found effect Defense")
		animated_sprite_2d.animation = "Defense"
		effect_label.text = "Defense"

When the effect is updated, everything gets printed, but the animations and the effect label wont change. I have tried changing them in the on_ready function and it works, but it wont when the signal function is called.
Im stuck, any help would be appreciated.

Thanks,
Ben
`

1 Like

Instead of set the animation property of the AnimatedSprite2D node, use the play method.

https://docs.godotengine.org/en/stable/classes/class_animatedsprite2d.html

1 Like

Hello and thanks for the quick answer,
sadly, this didn’t change anything…

Sadly, I still could not resolve this…
This might be an actual issue. Is there a way to reach support throught the forum?

You can make sure to call animated_sprite_2d.play(“Defense”) instead of just setting the animation property. If you’re still having issues, check if there are any other scripts affecting the animation.

Hello,
@hakkerbarry has already recommended trying this, and sadly it did not change the outcome. There is no other script influencing this object…
The object is created via script tho. It should not be, but might this be an issue?

My question remains… Is there a way to contact support?