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.
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:
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 groupwall
, and click and drag the mouse over all tiles, so they will be selected with the same color as the namewall
has.
Thanks that seems to be working now