How to make enemy follow path without entering solid objects?

A

ArchAngel

Guest
How to make enemy follow path without entering solid objects?

Im new to Gamemaker.
And im trying to make a little pacman game.


I want my ghost(enemy) to follow a certain path and that it dont overlap/enter solid blocks.

I googled and didnt find an answer, would someone, please, clarify?


I made a video showing the problem and how i set up the script. It's just 30 seconds long, full HD.


Any tip/help is appreciated.

~~
I know i can add an event to when the ghost collides with a wall, but what am i supposed to do? How can i tell it to avoid the wall? Or how can i make the path perfectly ?
I believe the event should be :

If Hit wall { reverse }

But follow path.
And the path waypoints should be perfect and not cause this.

What am i doing wrong?

~~
I tried decreasing snap to 16 but it didnt help.
Does the sprite follow the path but on origin (0,0) of the sprite?
 

Genetix

Member
You might want to read up on mp_path finding - should be exactly what you need. I'll share some code later when I'm home if it helps.
 
Top