0 votes

Hi.
I have seen a Sidescroller tutorial made in GMS on YouTube and decided it would be a nice exercise to rebuild the project in Godot Engine by using the techniques I have learned so far from the docs.

I am stuck for a week now at the problem described in the title.

I have set up a extremely simple state machine with various states (idle, run, roll, attack1, attack2, attack3) and they work with one exception. The rolling state.

Everything works as intended, but when I hammer the spacebar (which is the button for the roll state), the animation gets stuck in the last frame and does not transition to any other state anymore. To prevent this, i thaught making it mandatory to be in the idle or run state before it gets executed would help. But the problem still occurs. Here is the link to the code in my project.

Github Link to the Player character code

The part with the roll state has a comment (starting at line 49). You are welcome to make a PR. I am still realtively new to the whole version control thing but I guess I can handle it. :D

If something is unclear, I checked the e-mail notifictation for this thread to reply asap.
I really need help so I can sleep peaceful again. This is driving me nuts.

in Engine by (143 points)

in change_state, you are checking if the new state is different, but you still assign new_anim regardless. Either the if is useless, or was it intented?

To me the culprit could be this:

func _on_Animation_animation_finished(animation):
    match animation:
        "roll", "attack1", "attack2", "attack3":
            change_state(IDLE)

This will never run before your _process, always after, because the animation player is a child node. Perhaps this callback and your get_input function are running out of order and clash?

Hi Zylann, thanks for your time reviewing my code.

The if actually is useless and I now removed it. I think it was just a sign of despair, trying to figure out what is going wrong.

Anyways I noticed a weird behaviour earlier. When attacking (bound to Enter key) and instantly rolling (bound to Spacebar), the character switches to the second attack animation. This might have something to do with the same reason the rolling acts weird.

Thanks for your hint with the AnimationPlayer callback. I need to debug this. Really weird what is happening now. :/

Hi Zylann. Can you copy your comment into an answer? I would like to mark it as the best answer. Removing the signal unfortunately did not solve my problem with the animation being stuck, even though it was responsible for some crashes and generally weird behaviour. I think I rework the whole thing with a different approach.

Well, it was not really an answer since the exact problem was not found.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.