MZ Event keeps walking into the wall

I am trying to figure out how to make sure one event (event 1) can reach another event (event 2). When I use the snippet below event 1 will move towards event 2 until they hit a wall or corner. Is there a way so event 1 can pathfind around the wall to reach event 2?
No, for pathfinding you need a plugin.
Greetings,

You can use the following script to utilize the engine's built-in pathfinding for an event.

this.moveStraight(this.findDirectionTo(x, y))

Put that in a Set Move Route event command as a script and the event will pathfind towards the set coordinates. You'll want to put that into a loop in order for the event to keep moving towards the coordinates.

Break the loop once the event reaches the location you choose like this:
Capture.PNG


With further scripting, you could use a more complex route. For example, you could store your Event 2's coordinates into variables and then reference those variables in the above event code to have your Event 1 stop when it reaches a tile right before the coordinates of your Event 2!

Hope this helps and happy game making,
-Niniann
Greetings,

You can use the following script to utilize the engine's built-in pathfinding for an event.

this.moveStraight(this.findDirectionTo(x, y))

Put that in a Set Move Route event command as a script and the event will pathfind towards the set coordinates. You'll want to put that into a loop in order for the event to keep moving towards the coordinates.

Break the loop once the event reaches the location you choose like this:
View attachment 314948

With further scripting, you could use a more complex route. For example, you could store your Event 2's coordinates into variables and then reference those variables in the above event code to have your Event 1 stop when it reaches a tile right before the coordinates of your Event 2!

Hope this helps and happy game making,
-Niniann
Thanks, this solution worked out.

Original thread: https://forums.rpgmakerweb.com/threads/event-keeps-walking-into-the-wall.171172/