Hey RPG Makers!
Pathfinding has been greatly improved, allowing characters to pathfind around obstacles! Using Set Move Route, you can now use any of the following script variations:
- this.path(x, y)
- this.path(“event”, ID)
- this.path(“follower”, ID)
Using these, you can make any character pathfind to any point on the map, any event, or any follower. Yes, you can use this script on any character! So if you want to make events pathfind toward the player, or toward another event, you can!
Download Follower Control Plugin MV
How to Install
- Download the file, and make sure it is named TYR_FollowerControl.js and is saved as a .js file.
- Then place the file in your project’s “js” folder, within the “plugins” folder.
- Open your project in RPG Maker MV, then go to the Tools menu and select Plugin Manager. Use the Plugin Manager to add and activate the plugin.
Although this plugin is named Follower Control and focuses on player followers, the this.path() script can be used in the Set Move Route of the party leader, any identified follower, or even on any event.
There is also a command to determine the pathfinding ability of any character. You can use this on events, followers, or even the party leader!
Where value is the number of tiles the character is able to walk during pathfinding.
12 is the default value used in RPG Maker MV. This makes it so that when the player uses the mouse or touchscreen to move, pathfinding is limited to tiles that are easily accessible.
A very high number, such as 100 or higher, allows paths that are up to 100 tiles (or higher) in walking distance. This may be useful for events that are meant to have excellent pathfinding ability, such as ninjas or monsters that can see through walls.
A moderately large number, such as 30, may be useful in cutscenes, so that characters of that cutscene are able to walk from tiles on one side of the screen to tiles on the other side of the screen, even if there are obstacles in the way.
A small number, such as 5, allows only very limited pathfinding. This may be useful for certain events meant to have poor pathfinding ability.
If used on the party leader, keep in mind that this script will affect all of the player’s future pathfinding abilities, including when using the mouse or touchscreen.
But wait, didn’t we have a pathfinding script in Follower Control, already? Yes, but it was very basic. The old method remains, but the script call for it is now more aptly named as
The scripts this.path() and this.moveToward() both accept the same parameters. With this.moveToward(), characters will move directly along the shortest path, which may result in bumping into a wall. With this.path(), characters will pathfind so as to avoid obstacles.
Note: Through Off is needed for the new pathfinding to be utilized. With Through On, this.path() and this.moveToward() behave nearly identically. Keep in mind that followers by default have Through On, so you will need to use the Follower Control plugin commands in conjunction with Set Move Route to turn Through Off in order to see the effects of the new pathfinding on followers. Pathfinding with events and the party leader will have Through Off by default.
There are three different ways to use pathfinding, but all are accomplished using a script call inside a Set Move Route command:
Where x and y are coodinates on the map.
Where ID is the ID number of the target event, toward which the character will pathfind.
Where ID is the position of the target follower (in the marching order of the player’s party), toward which the character will pathfind.
Note: Each time the this.path() script is used, the character will only take 1 step toward the destination! If you need the character to take many steps, you can use the this.path() script many times within the same Set Move Route command.
Here are some things you can accomplish with the new pathfinding in Follower Control v2.00:
- Easily make cutscenes, without needing to be so careful in tediously calculating the exact positioning of every event in the scene and how it needs to move. You can let the this.path() script find the best move routes for you. You just need to know the target destination as coordinates, an event ID, or a follower ID.
- Create more interesting custom autonomous movement for events. This might include making events that appear to interact with each other, such as a dog that sometimes wanders but periodically approaches the player. Or, certain events that can wander may periodically move back toward their “home” location by targeting certain coordinates.
- Create a spooky enemy chase scene inside of a maze, because using this.pathMax() with a high value, the enemy will be able to track and pathfind to the player, with complexity of the enemy’s pathfinding ability depending on the pathfinding expertise (quantity of the value) you choose for it.
- Increase the player’s default pathfinding ability from the default 12 tiles/steps to any higher value, using this.pathMax() on the player’s characters.
Follower Control v2.00 Update Notes from the Help Documentation
Follower Control v2.00 Update Notes: January 24, 2019 This update greatly improves the pathfinding. As previously, you can use this.path() to make a follower move to specific coordinates, to a specific event, or to a specific follower. However, now the pathfinding allows avoiding obstacles. Note that in order for the follower to recgonize obstacles, you must also use the Set Move Route command to set Through Off prior to the movement. Then, use the Set Move Route command to run a Script of the this.path function. Examples of smart pathfinding that avoids obstacles: this.path(17, 5) -- This finds the smart path to x coordinate 17, y coordinate 5. this.path("event", 3) -- This finds the smart path to Event 3 on the current map. this.path("follower", 2) -- This finds the smart path to Follower 2. As previously, note that the follower will only move one step each time the script runs. An excellent feature is that you can use this.path() not just on Set Move Route of followers, but also on the leader of the player's group, or even on any event's Set Move Route command! Also importantly, if you use this in any cutscenes, the pathfinding calculation will remain the same, as long as the obstacles are in the same places! You also have control over the pathfinding distance! By default, RPG Maker MV allows pathfinding of up to 12 tiles, and this is what is used to pathfind when the player uses the mouse or touchscreen to move. But, with Follower Control, you can now change the pathfinding distance for any follower, including the leader of the group, so you can allow the player to pathfind even farther if you want! You can also use this to modify how smart enemies are at pathfinding! Use this script inside a Set Move Route command: this.pathMax(value) - Where value is how many tiles/steps you want the character to be able to pathfind around obstacles. For example: this.pathMax(30) - The above allows pathfinding around obstacles, even if it requires looking 30 tiles around to find the best path. If you want to use the previous pathfinding, which did not take obstacles into account, you can use scripts such as the following: Examples of basic pathfinding that does not avoid obstacles: this.moveToward(17, 5) -- This finds the basic path to x coordinate 17, y coordinate 5. this.moveToward("event", 3) -- This finds the basic path to Event 3 on the current map. this.moveToward("follower", 2) -- This finds the basic path to Follower 2. Remember that each script call moves the character only one tile, i.e. only one step.