Hello, I’m currently working on a “maze” top-down view game.
My cells are 16x16 pixels, and I’d like my player to move from cells to cells by “jumping” from one cell to another. Of course, I’d also like it to be impossible for him to pass through the walls…
So far, I’ve tried 3 different systems for moving, but none of them work as well as I’d like in terms of collisions.
Method 1
I’ve implemented the “PixelPerfectTopDownMovement” behavior on my player. With this behavior, the character “slides” and respects the distance in each moove.
In my events I set the condition “If player collides with wall” → Separate player and wall.
The problem is when the character “bumps” into a collision. Once done, if I then give him the right direction, he’ll make 2 moves instead of one.
Example: A wall is at the top, empty space to the left. I do up arrow → it doesn’t move (OK), then I do left arrow, it moves left then moves up by itself.
I’ve also noticed that sometimes with collisions the character tends to “shift” by a pixel
Method 2
I then tested another method of movement.
In my events, I assigned keys to directions and applied 1000px forces to my player on his X or Y axis depending on the directions I wanted to give him.
I also set the condition “If player collides with wall” → Separate Player and Wall”.
With this my character “jumps” well from square to square as I’d like… but he also jumps over walls…
Method 3
Finally, I had tried changing the X or Y variable by adding or removing 16 pixels, but as a result, it goes over the walls.
Does anyone have a solution for this? Thanks a lot