I drew a 2d Maze. How to collide with walls.


A top down game where I move a guy through a maze.
I drew a maze in paint and imported it in as a sprite (think pacman looking level)

I couldn’t think of a way to make my player trigger events when colliding with the walls.
I cant use 2d polygon collider as it tries to look at the sprite as a whole.

Ways I’ve thought, but I thought I’d just ask.

-Slice the sprite in the sprite editor, but I’d have to draw boxes over every single line.

-Research if raycasts can detect a certain colour. (I haven’t learnt raycasts yet)

-Learn blender and use the maze image as a guide and plonk cubes on it to make a 3d version of it.

-Recreate the maze in game using just a line sprite.

Is there an easier way?

Thanks in advance.

you have to figure out a collision maths that suits you. you probably mean you want the walls to be solid, you dont want to collide like bounce away at same speed you hit and in different direction, which takes more maths.

to make solid, just check position to see if it is in white or black, or check points aorund position to see if any is in black… if it is in black, change position to be +x and or +y the same so he is still moving forward up or left, but change one of the x or y so that he is not advancing into wall.