Freezing animation while pressing two buttons

Good day everyone!

So far I could solve all my problems with a tutorial or something similiar but this one is driving me crazy. Although I could find solutions on the internet, they wouldn’t work out or were not comprehensible enough for me.

My problem is if I press simultaneously two movement buttons for example W (upper movement) and D (movement to the right) it freezes my animation instead of playing the W animation.

It seems like Silver-Streak came up with a solution on this thread:

but I have no clue how to implement it. I tried it but it didn’t work out - I couldn’t wrap my head around which variable (string, boolean etc) he ment. Also I couldn’t find a “If” condition under:

https://wiki.gdevelop.io/gdevelop5/all-features/advanced-conditions/

I tried to solve it by my own ideas which also didn’t work out. I deleted everything and now I’m back to square one:

.

Second picture:

Hey, the problem is that the animation keeps changing between the 2 animations since your events trigger on every frame, so the animation freezes on the first frame.

Here’s a similar post with the same issue, and you can implement MrMen’s solution.

Hi,

Thank you for your answer. Unfortunately it doesn’t work. Actually no animation at all works now.

For the last action I used the expression “PlayerAnimation”, idk if thats a mistake. Also the other actions look diffrent than from the screenshot. On my screenshot it says:

PlayerAnimation: SET TO “RunRight”

on the shown screenshot it says

PlayerAnimation: = “RunRight”

I would say it’s the same but idk.

Edit: I also had the inverted conditions in it but deleted them afterwards to look if it makes a difference (nope).

Follow up post because I can’t post 2 pictures in one post. That’s the string I made on the scene:

My guess is, that im doing the string wrong (have no idea what im doing here).

The reason its not working its because your not telling it to change animations…

The whole thing has 2 parts…

First you make it so that when you press a key, you change a string variable to say something like “Up” or “Down”… what you made, that part is fine.

The second part… the part thats missing is making a condition that says “If scene variable “PlayerAnimation” says “RunDown””… the do the action "Change animation of player to “RunDown”…

Your just missing the second part :slight_smile:

You need to make it like this… change “UltraBlue” for your player character :slight_smile:

That last event, where the animation is set, remove the quotes around the variable name. The animation needs to be set to the value of the variable.

The rest of those events look fine.

Because you added the double quotes in the last event, you’re not getting the value of the string variable PlayerAnimation, instead it’s setting the animation to a string called "PlayerAnimation” (which doesn’t exist as an animation name).

You can either remove the double quotes and make sure the PlayerAnimation is added in the scene variables, or set the animation to VariableString(PlayerAnimation).

Oh! I just got it… thats pretty clever…

I thought he was missing the animation events, but your changing the animation by setting it to the string variable… thats pretty cool!

Thank you everyone for all the help! It works like a charm now: :slight_smile:

1 Like