so I’m making a game and there’s a bug where when you hit a wall you faze through it does any one know how to fix it?
Going through this there are some things to fix.
First off don’t use a variable named mySprite3 to determine which way you are facing. A better name would be facing. Adding some constants called RIGHT and LEFT will also help you with making your code readable so:
You can still use the move with buttons block just set vy to zero. Now you can add a simple up button pressed event to jump, but only if you are standing on firm ground.
I would remove walls from those little blocks in the corners. Marking the whole area as a wall while showing a tiny block is misleading to a player.
You also need to set the facing. An easy way to do that is to look at vx
Change the facing to the last direction the sprite was moving in. Notice there is no plain else. If you are standing still you will shoot in the direction you were last moving in.
After these changes Bob doesn’t fall down. So why was he doing that? You are doing a direct addition to the x position instead of using velocity.
By doing that Bob can jump over a wall instead of hitting the wall.
thank you