[solved] How to get collisions to work with tilemap and sprite

Hi, I’m currently attempting to create a maze game (for college) and I am struggling with getting the collisions working between the maze tilemap and the player sprite. Any suggestions or help would be appreciated.

I have been using the following link to attempt it and i can’t figure out how to get the player to stop moving when hitting a wall. I will also show the code I am using for the collisions as while I feel it should work to stop the player i can’t figure out how I can fix it.
{B342A23D-793E-413B-B37B-5B70B4D2FF91}

To resolve a collision, you have to move the player out of the overlapping collision boxes. So instead of a collision_event, you have to listen for a contact_point_response, and move the player in the direction of the normal vector, like in this example:

1 Like

This isn’t the issue I am having, there is at least at the moment only one hitbox at once that I am trying to get my character to be stuck behind. At the moment it is letting my character run through the walls. I may be able to use this in a later part of my code but I am trying to make it so my character can’t go through the walls in any way. If you want I can upload my project for you so you can see exactly what I mean as I may not have explained it in the clearest way. I will continue to look through the docks to see if I can figure it out myself as well.

Which part of your problem is not fixed by that solution? This will make it so that your character can’t go through walls. With just two steps per frame, moving the character, and fixing the overlap. So they will stop exactly at the wall.

I don’t know exactly what the issue actually is but there doesnt seem to be any messages sent to anything in the script as far as I can tell. The link below is to a github repo of my project so I hope you could offer me some advice on either how to fix it or what I may have done wrong
https://github.com/StrategicVirus/MazeChallengeDefold
Also sorry for the lack of comments if it makes it harder for you

This project is set to private.

ah sorry, it should be fixed now

There are two problems:

  • The player collision object is not centered on the player. Click on the collision shape Box, and set the x and y position to 0.
  • walls.tilesource had a collision group added, but no tiles selected for it. Click on the collision group wall, and click and drag the mouse over all tiles, so they will be selected with the same color as the name wall has.
3 Likes

Thanks that seems to be working now