How to Change Events to move towards Player if players gets close enough

I understand there is a Yanfly plugin that does this but I'm not sure which one it is. I want events/monsters to move randomly until they get close enough to a player or vice versa. Then they should chase them up to a certain distance from their base location. How could this be done (or most of this) without creating lagging gameplay?
I understand there is a Yanfly plugin that does this but I'm not sure which one it is. I want events/monsters to move randomly until they get close enough to a player or vice versa. Then they should chase them up to a certain distance from their base location. How could this be done (or most of this) without creating lagging gameplay?
It's Yanfly Event Chase. To reduce lag just put wait five frames (or however often you want the script to run) at the end of the move route
I'm doing a puzzle event similar to what you are describing. It uses using Parallel Process (which means that you need to look for a follow-up solution when you want to use the "On Event Touch" trigger). It follows you when you are close enough and goes back into idle when you run away from it.

1677398731834.png


Example of the Script Command:
Code:
$gameMap.distance($gamePlayer.x, $gamePlayer.y, $gameMap.event(this.eventId()).x, $gameMap.event(this.eventId()).y) < 3

In the end, this is just an alternative, you may prefer Yanfly or Visustella Plugins here.
Ups i overrread that it was allready posted.

If you want to use the Scriptline in Event Commmands, there is a another possible solution.
I remember @caethyril mentioning it in the past.

$gameMap.distance(x1, y1, x2, y2)
and the Code to use would look like this for variable1:

$gameVariables.setValue(1, $gameMap.distance($gamePlayer.x, $gamePlayer.y, $gameMap.event(1).x, $gameMap.event(1).y) )

Than use Variable1 for the Conditional Branch.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-change-events-to-move-towards-player-if-players-gets-close-enough.155325/