im trying to Remake pac man can someone give me some tips on how to recreate the ghost AI?
Can you tell me how you would like the ‘Ghost AI’ to behave? (What does it do in the real game?)
I haven’t played much Pac-Man.
I don’t know much of the actual workings behind the game, but I know each ghost has a bit of its own personality in how it chases the player.
I think the best way to do this is just to find a YouTube video on how the ghosts work. Pac-Man is a very popular game, so I’m sure there are some high-quality videos detailing how the ghosts work.
After that, you should get an idea of how the “follow” logic for the ghosts was coded. That should point you in the right direction and then you should be able to ask questions here in more detail. Right now it’s quite vague and it’s hard to help when the question is basically the entire ghost and not a specific quality of it.
This should be of some use to you. You’ll want to adjust the system so that the Arrows snap to 90-degree angles. At the start of the game you’ll want to do a simple Ray Cast check of which direction the Arrow cannot face so that if it tries to point that way, it will go in the next closest direction.
The simplest type of true pathfinding goes like this:
The objective object (this case the player) spawns out four arrows or waypoints in the four cardinal directions, up, down, left, right, to the places on the grid next to it.
Those arrows will check all four directions, if there is no block in that direction, it will spawn another arow or waypoint in that direction.
So these arrows will spread instantly across the map, until it is full. Then, AI can read what block it’s standing on, what rotation it is at, and go the opposite way. This will adventually lead to the objective.
Here is what it looks like visually:
However, in certain cases you can imitate true pathfinding very closely. You can raycast in the direction of the player, then splice out raycasts farther away from the direction of the player, until it doesn’t hit a wall. This, however, has some downsides.
But is there a way for the ghost to move in different paths, as that is a very important part of pacman.
how do i do that? that is what i want but i also want them to chase pac man
Do you want the ghost to travel in straight lines?
yea but i dont know how to do that
Hmm… you’ll need paths set. Ther might be another way, but I don’t know.
We might be able to use this.
nope, aint trying it too much code
Hmm… Well, if you aren’t willing to try, then I don’t know how to help you.
im just kidding man.
Lol! I thought you were! No Flowlabber I’ve talked to ever gave up.
So, in this example, the enemy can follow a straight line. All we need to do is find a way to set the straight line.
Maybe we can set checkpoints at all of the corners. Then the enemies can follow those.
Darn, that sort of puts us back where we started. I know there’s an easier way to do it, I just can’t put my finger on it.
but how about we try something with raycast like when a ghost is in front of a wall, they check to see if there is a wall in front of them and if there is, they can go up or down but if thereis no way to go up they go down
This might work. We’d just have to use a special raycast system and a few randomizers.
Four raycasters (32):
Let’s start with this. We have four raycasters that all go into a router.
If raycaster 1 hits, that means there is a wall Infront.
If 2 hits, that means there is a wall under.
If 3 hits, then there is a wall to the back.
If the final raycaster hits, then there’s a wall above.
Flowlab Game Creator - New Game can you put that code in my game and see if it works?
nevermind im trying it
I’ll show you a screenshot once I finish. I’m glad you’re trying!
ok but are you almost done?