I was working on movement behaviors for the player in one of my games. I was becoming quite frustrated with the jump code because the “switch” and “proximity” blocks weren’t doing what I wanted and expected. So I played around some more and noticed something interesting. Take a look at the images I have attached.
In this picture, what I want to happen is this: If the player is close to a gray ground block, then turn the switch on. If the switch is on when the spacebar is pressed, send a signal to jump AND turn off the switch. Once the player is close to a gray ground block again, turn on the switch.
What was actually happening is this: The switch would not turn off after one jump. It would stay on until the player did an “air jump.” So the player was getting two jumps when they should only be getting one.
In this picture, I assumed the code should work exactly the same. But it didn’t. Simply moving the “proximity” block back behind the key press block made the code work as I wanted. The player got one jump, then the switch turned immediately off, until the player was close to ground again.
I’m not sure if this behavior is intended or not. If it is, I had no idea, and it was quite frustrating to figure out. My movement behavior does work as intended now, though, since I have moved my code to match the second image.