Npc Movement Type: Approach

● ARCHIVED · READ-ONLY
Started by Popnfizzle 14 posts View original ↗
  1. Hello everyone,

    I've been having some difficulty trying to figure out how to get NPCs in my game to move the way I want them to.

    Basically I want the NPC to constantly approach the Player. Unfortunately the programming for the
    Autonomous Movement Type: Approach has a flaw in its design.

    I would like to make it so these NPCs will approach the Player but if there is a solid wall between them they will path
    around it instead of just standing there staring at a wall.

    Example:

    This is how the pathing works currently. As you can see after the player runs to the bedroom the zombies will face him
    and stop on the other side of the wall.
    pathing 01.png

    But I'm trying to make them do the following instead. Even if the player is in another room the zombies should path
    to the room instead of just looking at a wall. Like this.
    pathing 02.png

    Now preferably if I could set it so only certain walls block line of site and cause this pathing that would be great.
    Pretty much only if the zombies cant see the player realistically such as through a wall would this happen.

    Not sure if I explained this well or not but any help would be appreciated.
  2. This isn't a flaw. This is originally how it is planned for MV and all other engines in the series. You need a line of sight and pathfinding plugin. There are plenty around if you search the net.
  3. You want a pathfinding script for it to work like that. I'll move this to plug-in requests.
  4. This isn't a flaw. This is originally how it is planned for MV and all other engines in the series. You need a line of sight and pathfinding plugin. There are plenty around if you search the net.

    I apologize. By having a flaw I didn't mean it is flawed in it's design, I know its working as intended, I meant for what I was needing its flawed. I should have used a different word or phrase I guess. Its more like my needs are not met by the original coding of the Autonomous Movement: Type Approach.
  5. You want a pathfinding script for it to work like that. I'll move this to plug-in requests.

    TY, I always have a hard time finding where to put questions on here lol, wasn't sure if I needed a Plugin or help with Event setup.
  6. Shaz said:
    https://forums.rpgmakerweb.com/index.php?threads/smart-pathfinding.46761/

    Try this. I just can't recall if it pathfinds around obstacles - I THINK it does.


    I tried to use your plugin, but unfortunately Im looking for something that will automatically pathfind without being activated.

    Basically Im going to have zombies on a map and they will always be moving towards the player and when the zombie event touches the player it activates the event, normally I could put it as a Parallel activation but then I cant have an event activate when it comes into contact with the player. Here is the event.
    zombie event.png

    I tried Yanflys EventChasePlayer plugin too which is applied in the move route of the Automatic Movement and unfortunately it just makes the Zombie do the same thing as the Type: Approach option which just makes them face the wall not actually path to them like I need in the Second example above.

    I did see someone asked if you were going to make it so it could be called with the Script Call option in the move route instead of having to use the Call Plugin option which can only be used when the even is activated.
  7. I don't understand why you would need a parallel process trigger on that. And I'm not sure what the issue is you're having with my plugin.

    Put a parallel process event that calls the plugin for each event you want to approach the player, followed by an Erase Event command. All of those events will continually pathfind to the player until you tell them to stop, or until they reach the player. If you have them set to Event Touch with your commands, they will pathfind to the player, then the event will run.

    However, having many events trying to pathfind at the same time may cause lag, no matter which way you do it.
  8. Hrmmm, I think I was looking to close at the event and as they say "couldn't see the forest for the trees" I didn't even think about using a separate event that would activate all the pathfind events. Let me try that and ill see if it works and ill let you know.
  9. Unfortunately Shaz, I tried using the parallel process on a separate event and the plugin is working. Its making the Zombie move towards the player but as soon as the player turns a corner and gets opposite a wall like in the pic in the original post it still just pathfinds to the wall facing the player and stands there. I don't think the issue is with your plugin, its working fine, but I just don't think the pathing allows for what Im needing. :(
  10. sorry. Was worth a shot.
  11. Yeah I know, thanks. I might need to learn to make my own plugins to get what im looking for lol
  12. Hmm..... If you paint the wall with a region. Then create a common event to check for the player's location, and create a Region Check common event to check if the space in front of the mob is that region... You can then run the Player Location common event, followed by the Region Check event. If it isn't the wrong region have the event move towards the player, and if it is have it check the coordinates to the sides of the zombie. If it doesn't find that region have it move that direction.

    Or if you want to get really fancy have it check coordinates beyond that as well, and if it discovers multiple opens spaces have it move that way. It's very complicated, but technically the if checks there expanded far enough could create a fake pathing A.I. Going to be savage on your resources though, better include a lot of wait commands so these events don't run too often.

    Not going to lie, this is nightmare fuel levels of eventing.... I'm probably going to edit my own pathing setup to include it. :LZSexcite:

    Optionally you could try http://www.yanfly.moe/wiki/Move_Route_Core_(YEP) it apparently checks 12 iterations with it's move to player commands. Probably the better call if you're not into eventing masochism. :LZSwink:
  13. You can achieve a basic "always path to player" thing with a fairly simple scripted move route, since RMMV has a built-in pathfinding algorithm.

    Try setting your event's auto-move type to "Custom". Set the move route to "Repeat" and "Skip if Cannot Move", then give it a single Script command:
    Code:
    this.moveStraight(this.findDirectionTo($gamePlayer.x, $gamePlayer.y));
    You may want to set the event's frequency to "5: Highest" (i.e. no delay between moves). Then you can set the event's trigger to Event Touch and put whatever commands you like to run when the zombie catches you~ :cutesmile:

    (Note that this method will still make the event walk into walls if there's no valid path to the player.)

    Edit: if that doesn't work out, then it's probably an issue with the pathfinder's node search limit vs your map size. By default the limit is set to 12 tiles: it'll search that far from the current position for a tile closer to the target. You can override the limit with a small plugin (I think Yanfly's Move Route Core has this option built-in):
    Code:
    Game_Character.prototype.searchLimit = function() {
        return 12;
    };
    ^ Change the number to whatever you like: increase for better long-distance pathfinding in exchange for higher CPU usage when pathing. Then save as a .js file (Save As > File Type: All Files, Filename: whateverYouLike.js), import it like a plugin, and save your project.