I'm making an event trying to get away from the player and every time it gets caught, it gets faster until it's on Speed 6 and Frequency 6. I'm using a parallax map and even used the Yanfly Region Restriction to prevent it from getting stuck in a corner. But the "move away from player" doesn't quite work as intended, even when in custom movement I put "move away from player" on loop. Maybe I should use a script or am I overlooking something?
Problem about moving away from player
RPG Maker MV Support"Move away from Player" literally just tries to move away from the player. If you want to account for walls etc then you'll need it to search for a path around obstacles. That's called "pathfinding".
I posted some relevant plugin code here, in case you want to try it out:
forums.rpgmakerweb.com
Plaintext-to-plugin instructions:
I posted some relevant plugin code here, in case you want to try it out:
How to make event properly run from player?
If i am setting the route-move away from player, it usually runs in straight line and gets stuck either in the corner of the map, or behind the object. Is there a way around this, to make event look for escape patches instead of just going in opposite direction?
forums.rpgmakerweb.com
- Copy + paste the code into a text editor (e.g. Notepad).
- File -> Save As:
- File Type: All Files
- Filename: whatever.js
- Import that file as a plugin.
- Save your project to apply Plugin Manager changes.
- Test!
Alright, so I tried the script and even though the movement has improved, the npc doesn't move away from the player unless the player walks around the npc.
any event can only have a single move route assigned to it at any given time, but in your original screenshots you have used both methods to assign a move route - the set command and autonomous movement.
if you use both they overwrite each other without ever completing any one.
have you already corrected that or is it still messing up your path?
anyway, please show screenshots of what your current event/move routes do after the change so we can look for remaining problems it that.
if you use both they overwrite each other without ever completing any one.
have you already corrected that or is it still messing up your path?
anyway, please show screenshots of what your current event/move routes do after the change so we can look for remaining problems it that.
OK, first: I didn't notice earlier, but like Andar said, if you change the event page then the autonomous route on the new page will replace any route you've given it via Set Movement Route. Page 3 of EV089 sets a move route, then sets the variable to 5, which I guess will make the event change page, so the Set Movement Route command does nothing. A couple of ideas:
- Make a new event page specifically for "running away", and put the movement into that page's Custom autonomous move route? Or...
- Use a single event page with Conditional Branch and Set Movement Route commands to handle all of its movement. (There is a move command to set the character's move speed.)
The post I linked before mentions 2 possible approaches:
- Use a Script command in the move route, instead of "Move away from Player".
- Replace the "Move away from Player" logic with pathfinding.
This pathfinding logic might still fail in certain map layouts because of the search limit. (It's also possible that I made a mistake in my code!) So, as well as screenshots of your event pages, it could also help to see a screenshot of the place(s) where your events are getting "stuck".
Also, just as a quick reminder: by default events cannot move through other events unless at least one of them is marked "Through", either via the checkbox in the bottom-left of the event page, or from a "Through ON" command in a move route. It doesn't matter whether the event has no image, is Below characters, etc: if it's not marked "Through", it will block other events. This also applies to followers (player party members). Some plugins (YEP_CoreEngine?) might change this.
Here, it moves away only when the player moves 1x1 closer instead of continuing to run away from the player.
Tried to make the ghost's movements into a different parallel event, but the problem continues.
The first approach seems safer, but how do I activate the script command?
Actually I have the YEP Core Engine (mostly to change the screen to 1024x768)
That looks like a passability issue: it seems to avoid moving onto certain tiles. Are there events or blocking regions on those tiles?
In the move route, instead of Move away from Player, use:
- Script:
this.moveStraight(this.findDirectionAway($gamePlayer.x, $gamePlayer.y))
Yes, I am using YEP Region Restrictions to avoid the ghost getting stuck in trees (3 is All Restrict, while 2 is NPC Restrict only)
EDIT: Used your script command and it works perfectly now. Thank you!
Oh nice! You're welcome~ 😂
Original thread: https://forums.rpgmakerweb.com/threads/problem-about-moving-away-from-player.182736/