Random beginner-question #14: Animation plays only sometimes...

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

Hi everyone,

I wonder if maybe someone had a similar problem once.
Holding down my button creates a timer which sends a signal after 1 second.

func _process(delta):
	timer += delta
	if Input.is_action_pressed("mousebuttonclick"):
		if timer >= 1.0 and not being_pressed:
			being_pressed = true
			print("button held for 1.0 secs")

The signal starts an animation above the button, a bar filling up. The idea is: releasing the button within the first second opens a popup#1, holding it until the bar is full will open a popup#2.
The process can be canceled which will interrupt the filling-animation, replacing it with a “canceled”-animation (the bar blinking shortly).
Both popups and the fill-bar-animations are all packed in their own scenes.

All this works smootly until I once hold the button for popup#2 to open. After closing this popup, when klicking and holding the button again, the counter starts, the print shows up, but the fill-bar-animation does not. (This problem does not occur with popup#1.)
Cancelling, however, will show the blinking animation and only after that a new press/hold shows the fill-bar-animation again as it should be! (Until opening popup#2 again…)

I have no idea what could cause that omitting the animation at that point. Is the signal not being sent? Is it not received? Some loop somewhere not finished?
I tried get_node("FillupAnimPlayer").stop(true), different signal paths, pushing a very short “invisible”-animation in between, timer = 0 in places… nothing helped.

Does this seem familiar? Suggestions would be much appreciated.

:bust_in_silhouette: Reply From: pferft

Well, for all who might stumble over the same problem: I just replaced all the little animations with new ones and voilà, problem solved.

I’m not sure why, but it might be connected to my copying the whole project-folder (keeping the original as a backup I won’t touch anymore, which I regularly do albeit not having caused such troubles yet). Maybe the animation player got confused…?

You should probably take the time to get to know Git (or other SCM software). That would make managing various versions of a project simple, allow you to easily move between different versions, tests, and experiments - as well as serve as a cloud-based backup.

Well worth the time investment IMO…

jgodfrey | 2020-09-03 21:02

Thanks for the tip, I’ll look into it!

pferft | 2020-09-03 21:10