Hey does anyone have any good suggestions when making AI for a pac man game? me and my friend have been trying to make a ghost that either goes through the maze or even better follows the pac man? We have been trying to make this for a couple of days but have had no luck
Making a ghost follow packman would be difficult (but not impossible), I would recommend doing something like this:
Have a randomizer chose a direction and use a ray cast to see of that direction is blocked, if it isn’t have the ghost move forward until it hits a crossroads, you can mark these with invisible blocks. When it does, chose a new random direction and repeat. If the first direction is blocked, make it so that the randomizer repeats and chooses a new direction. Or add one to the number, also changing the direction.
This should work, you might need to change some stuff if I got something wrong though.
I’ve done my best to make a good AI, it sometimes gets stuck on walls and reverses direction for unknown reasons, but 98% of the time it worked for me.
In order for this to work for multiple ghosts you will need the intersection block to send messages to each of the ghosts individually when they collide.
This was pretty difficult and I would love to see some flowlab experts try to make one of these.