MZ Need help with event movement towards the player

Heya,

What I'm trying to do is create an event for an enemy that approaches the player, synched to the player's movement, and triggers an encounter. I haven't gotten to the latter yet, but right now I'm trying to figure out how to make the enemy movement less dumb.

I want the event to be able to navigate through the maze I set up to reach the player's current position, but I have no idea how to accomplish this. Right now, it's doing the very RPG Maker thing of trying to run into the wall to reach the player as oppose to navigating around it.

I'm using Visustella's EventMovement Core for the synch movement. Any help would be greatly appreciated.
I want the event to be able to navigate through the maze I set up to reach the player's current position,
You use a pathfinding script or plugin. There is A* pathfinding built into the engine, it's what's used when you click the screen and the player pathfinds to it.

You put this in the event's move route
this.moveStraight(this.findDirectionTo($gamePlayer.x,$gamePlayer.y))
You use a pathfinding script or plugin. There is A* pathfinding built into the engine, it's what's used when you click the screen and the player pathfinds to it.

You put this in the event's move route
Thanks. I put that code in the move route and set the <Move Synch Type> to Custom, and it worked to a satisfactory degree. It doesn't quite know what to do with getting around particularly long corridors, but I can probably fix that by altering the design of dungeons themselves.
There's a built in pathfinding limit of 12 tiles or so. You can overwrite it with a plugin file but it's there because pathfinding is an expensive process in terms of system resources and the longer the path the more lag you get.

Original thread: https://forums.rpgmakerweb.com/threads/need-help-with-event-movement-towards-the-player.173403/