Platform Gymnastics - Sprite stuck against wall

Hi All,

Trying to get a Mario inspired platform game in order to teach platformer techniques. A major limitation is that there is only one type of wall so really need to check how (left or right) we are colliding with the wall. I had to add this change y by -1 to prevent my mushroom from getting stuck against the wall.

If you change the -1 to 0, you will see the stuck behavior. To trigger a mushroom, have Mario jump up into a block. FYI: the scoring is just to help the debugging.

Anyone know why this is happening?

Here is the link:

Whenever a sprite hits a wall, all velocities stop. Unfortunately even setting the velocity in the opposite direction does not work within the same event block (however, changing the y position does get it to work).

In my games when a sprite hits a wall, I would go to all sorts of trouble to try and get it move in the opposite direction. For instance using the ‘sprite data’ extension, storing the speed as data variable to the sprite, and using a ‘timer’ method, I would then have the sprite move in the opposite direction after some time had passed.

Changing the Y value to move it off the wall works really well, although you do see it jump just a little.

The issue here is pretty subtle; it’s hitting the wall to the side, but is also hitting the wall to the bottom (due to the ay), and in both causing it call the ‘hits wall’ code twice – and in each case it’s hitting the wall to the left / right. Ideally you want to check is { location } to the left / right of { sprite }, but I’m not sure we have a super easy way to do that right away, even with the tilemaps extension (besides manually comparing row / col). Several possible fixes for now:

instead of setting to vx*-1, just set a specific vx; hitting two walls in a row won’t matter as they’ll just be resetting vx to the same value:


If maintaining each enemies vx is important, you can clear ay when the enemy is standing on a wall and set it back whenever the enemy isn’t standing on a wall:


Thank you for explaining this. The changes were minor but it has improved the game dramatically.