Problem with character jumping

In my project, I have a problem: when my character is cycling through it’s run cycle while im holding the arrow keys, i have to stop the character, and then press space in order to make him jump. basically, I would like for my character to automatically go into his jump when I press the space bar, without me having to stop and then press it. For some reason, it doesn’t work.

If It’s hard to understand what I mean, here’s my project:
Testing stuff5-4-2022_21-03-39.wick (204.0 KB)

1 Like

You could fix this by making sure that the character isn’t jumping while the user is using the right or left keys before making the character move in that direction.

You can use “this.currentFrameNumber” in order to get the value of the current frame that the clip is in. I see that frames 4 and after are for the jumping animation, and therefore what you can do is check that “this.currentFrameNumber<4” in order to know that the character isn’t during a jumping stage before having them move right or left.

You can also use “if(isKeyDown(‘key’)){ … }” or “if(isKeyJustPressed(‘space’)){ … }” and an “else” statement in the update script rather than having the code be in three different scripts (keypressed, keyreleased, and keydown). But your current method still works.

Here’s an example, I organized my code a bit differently than how you had it but it uses the same ideas I shared in this post- Testing stuff5-4-2022_19-23-30.wick (204.0 KB)

1 Like

Thanks very much! I didn’t even consider that.

1 Like