Hello,

Not sure if this is bug or the way PLAY BACKWARD is implemented, so: (sorry i don't know how to set this to show code in window )

Example: Using Animation Sprite node.

this works OK


if Input.is_action_pressed("ui_down")
	Sprite.play("Crouch")
if Input.is_action_pressed("ui_up")
	Sprite.play("Crouch",  true)  #plays in reverse

this doesn't work, it just skips animation - no backward play


if Input.is_action_pressed("ui_down")
	Sprite.play("Crouch")
	# ...some code..
	Sprite.play("Something_else") #change to some other animation
if Input.is_action_pressed("ui_up")
	Sprite.play("Crouch",  true)  #plays in reverse

There is workaround if you set animation and frame of the animation before calling BACKWARD play like this:


if Input.is_action_pressed("ui_up")
	Sprite.animation = "Crouch"
	Sprite.frame = Sprite.frames.get_frame_count("Crouch")
	Sprite.play("Crouch",  true)  #plays in reverse

To sum it all up, if you change animation to something else, GoDot doesn't know how to play backwards previous animation.

thanx

fixed the mistakes

OMG i just cannot format this text to show correctly :(

Looking at the code, the problem could be how you are calling the play function. I think it needs to be Sprite.play("Crouch", false) to play backwards.

That said, I think the Godot editor would complain, so this likely isn't the issue. This sounds like a bug, so I would report it to the Godot GitHub repository, after searching to make sure no other issues on this bug have already been opened.

Out of curiosity, does the following work:

if Input.is_action_pressed("ui_up"):
	Sprite.play("Crouch")
	Sprite.play("Crouch", false)

If this works, then it might be something is not being properly set when the reverse flag/boolean is true and the animation is different then what is already playing, which would defiantly be a bug.

(Side note: welcome to the forums!)


OMG i just cannot format this text to show correctly :(

I reformatted your post :smile:

You can edit your post to see the changes I made. The changes were primarily replacing dashes (-) with underscores (_) to tell Markdown to make a horizontal line, removing the #, indenting all of the code blocks with a single tab so it is formatted as code, and removed all of the > characters.

Hi,

Thank you for reformating. Firstly i just used standard text with symbols and all went to hell, so i tried to quickly fix it to be at least readable. :)

Regarding my code, it is not directly copy/paste, i wrote it here directly made a few mistakes with quotes and also a mistake writing FALSE as it should be TRUE (for BACKWARDS). Didn't make this mistake in my real code.

i will fix my first post

Looking at everything again, with the corrected code, I don't really see what would be causing the animated sprite not to play backwards. If I had to guess, it is likely something isn't being set correctly in the Godot code when the animation is supposed to play backwards.

I would suggest opening a bug on the Godot GitHub repository, since this is almost certainly a bug.

3 years later