Inconsistent jumping

[I am making a game with a friend for school, we only want the character to jump only when on a platform. This works, but sometimes it will not let you jump.]

Game:

(Game Lab - Code.org)

What I expect to happen: [The character should jump when pressing w or up arrow, and only when on a platform]

What actually happens: [You will only sometimes jump]

What I’ve tried: [I’ve tried making the character move slower, and jump less high.]

I hope you can help!

Using an Or and an AND inside a conditional creates a lot of moving parts.

Also, keyDown probably would work better than keyWentDown.

I would probably start by using only the up key to jump and removing the or statement. Then, use keyDown instead of keyWentDown … then, if you are still having problems, check back in!

Good luck!

Mike

This worked, although it wont let me jump on the first platform of each level without moving left or right at the same time.

Thank you,

Micah

That could be the “fall” function that is constantly changing the velocityY. It could be that it doesn’t stay at zero long enough for the jump to happen, but I’m not 100% sure. You may try moving the jump function below the fall function and see if that changes anything.

Mike