How to approach PacMan like character movement?

Hi all,

I’m working on a PacMan like game, I’m making the maze with tilemap, but then I was wondering how to approach the character movement on the maze where the character moves in straight line and do 90` turns.

I first implemented collision on the map but that doesn’t make the movement like PacMan.

So what’s the best way to implement this?

Regards

Hey !

Did you implement any movement yet ? Do you want to know how to move your player or how to rotate it ?
What I would do is:
When you press any directional keys, you want your pacman’s velocity to be one of the following Vector2 : {1 ; 0} (right), {-1 ; 0} (left), {0 ; 1} (down), {0 ; -1}(up).

Then for your player’s rotation you want to set it to 0 (right, left) or 90 (up, down).
In order to have your pacman always looking the way you want, you should check on your sprite’s flipH and flipV properties.
This will allow your sprite to never look upside down.

The collision on your tiles will block your player inside your drawn map.

I hope this will help you getting closer to your goals.

Regards !

Hi, yes the problem is that the character gets stuck when trying to turn, that’s why I’m wondering maybe implementing some grid movement.