Help with Script

Hey there Rpg-friends! 🙂

I'm working on a game. So my question:

Is there any way to let an npc(enemy) follow the player. It should be the player is running through corridors of a maze while the enemy follows him all the time. If he touches the player it's game over.

Simply letting the event walking straight to the player ends in hanging in the next corner of a corridor....

Maybe someone has an idea? This would be awesome!

Many thanks in advance! 🙂
You should change the title, as there is no script used in that. But if you set it to movement -> Approach it will chase the player as best as it can. Note though events cannot go through other events, so you will have to make sure the maze has no events at all blocking the path.
Approach it will chase the player as best as it can.
Keep in mind that while that is true for the large majority of situations your event might act a bit weird when the player is not moving (sometimes even moving away from the player). This is not the only issue here.
If the fastest path connecting your event and the player leads to a wall - as an example - the event will be stuck trying to pass through that wall.

The way "Approach" works is just like this:
- calculate difference between player x,y and event x,y
- pick a direction based on those coordinates (I don't know which one is picked first, never checked)
- move toward that direction

For this very reason it only moves calculating the fastest L-shaped or straight path regardless of obstacles. This might work for you but you have to set up your maze properly. If you test it and it doesn't work you should do this in a different way. If I am not wrong Shaz has a script that allows you to move events using a path (I don't remember if it only works for the player though).
I do have a pathfinding script, but it was written for the player only, and it's quite CPU-intensive. I think I worked out a way to make it work for events as well, via a script call, but if you had several doing it, it could grind your game to a halt. Might be worth a search.

Original thread: https://forums.rpgmakerweb.com/threads/help-with-script.104858/