Overlap issue that we can't figure out!

I have a student who is building a game in which you have to move through a level while avoiding a shark. The goal is to get to a trigger for the next level, and if the shark touches you, a life is lost and you both reset to the beginning positions.

The problem is that at the very beginning of the game, before anything happens or the sprites even move, the shark seemingly “glitches” through the tilemap walls and hits the player, harming him, without ever overlapping the player.

Code is below! Any advice would be very appreciated.

Game Link

haha L

The issue is that you are placing your sprites before the tilemap exists:

Just move the “set tilemap to” blocks before the “place on top of tile” blocks and you should be all set!

To clarify my answer, the place on top of tile blocks don’t do anything unless a tilemap already exists.

This worked! Thank you! However, when reaching level two, if you get hit once by the shark, he moves through the tilemap and hits repeatedly until game over. I think that is because the mysprite / mysprite 3 overlap places the sprites back to their level 1 position, instead of the new starting positions for level 2. I’m not sure how to correct this. Any ideas?

Well the easiest way is to use that current level variable you have:

Typically, the way I do this sort of thing is to make special tiles that mark where the shark and player should spawn. Then, you can avoid having to hardcode position locations like that. Instead, you can use the “place on top of random tile” block to place the shark and player onto the special tiles you created. Sorta like this:


Here’s the code:

If you want to hide the special tiles, there is a block for doing that in the tilemaps extension