So - weird thing. Can't seem to wrap my head around it.
I have a stamina meter that drains when my player runs. When it hits zero, they can't run again until it recharges. It recharges faster if they don't hit zero. This has been working great and my code does what i need it to do.
But I am adding a visual prompt, a simple AnimatedSprite, to simply become visible whenever the player gets "exhausted" and tries to run.
But here's the kicker: EVERY PLACE I PUT IN ANY REFERENCE TO THIS SPRITE, MY CODE NO LONGER WORKS.
It's always wherever the stamina meter empties and no matter where I put this tiny bit of code, it breaks the whole thing (specifically, once my meter empties, it no longer recharges). I tried avoiding using yield, and tried using it, and the same result both ways. Have also tried signals. Is there something up or is this a glitch?'
UPDATE: It seems to have something to do with the visibility turning on and off too quickly? Seems when I made it just hang until the flag expired, everything works on. But even MORE curious - when I tried adjusting the modulate in the editor on this AnimatedSprite so it was a little clear (since it apparently has to linger now) THE BUG HAPPENED AGAIN. Makes zero sense - seriously, I am STUMPED. It's like adjusting the visibility at all causes some yielding in my stamina functions (also weird, since they are executed per frame/signals).
func _ready():
var _exconn = _exPrompt.connect("animation_finished",self,"_exPrompt_off")
### then in my state machine:
if exhausted:
_exPrompt.visible = true
### then at animation_finished...
func _exPrompt_off():
_exPrompt.visible = false