How to make an NPC reflect the player?

In RPG VX Ace, I've been trying to make an NPC that follows the player exactly when they move. By this I mean when they move left/right, the NPC does the same. However, when they move up/down, the NPC moves down/up. Put simply I'm looking to make an NPC that works like your reflection in a mirror. The NPC also shouldn't move if the player is unable to, like walking into a wall.


There's two problems that come up with this; first is that the way player frequency works, an NPC entity always lags behind to some extent and looks unconvincing. Second is that through all my searching of a script to use, there's only been one that gets close to what I've been looking for but it mirrors the player movement, not reflect it. I've forgotten who this belongs to so apologies but it was buried pretty deep in this site and I'm pretty sure the actual thread is gone now.


class Game_Event
def page_notes
return '' if @page.nil? || @page.list.empty?
@page.list.select {|c| [108,408].include?(c.code) }.map {|c| c.parameters[0] }.join($/)
end
def move_with_player?
page_notes =~ /<move_with_player>/i
end
def move_by_input
if move_with_player? && movable? && !$game_map.interpreter.running?
@move_speed = $game_player.move_speed
@move_frequency = $game_player.move_frequency
move_straight(Input.dir4)
end
end
alias update_move_by_input update
def update
move_by_input
update_move_by_input
end
def movable?
return false if moving?
return true
end
def dash?
move_with_player? ? $game_player.dash? : super
end
def debug_through?
move_with_player? ? $game_player.debug_through? : super
end
end




You activate it by selecting comment in an event and using "<move_with_player>".
Are you asking for help to get that script to work (in which case, this needs to be in Script Support), asking if there is another way of doing it, or...?


My guess is that if you can't get that script to work, you will have to ask for one (so Script Requests) as I don't think what you want can be done without one.
I'm asking how achieve the above explanation. That is,

In RPG VX Ace, I've been trying to make an NPC that follows the player exactly when they move. By this I mean when they move left/right, the NPC does the same. However, when they move up/down, the NPC moves down/up. Put simply I'm looking to make an NPC that works like your reflection in a mirror. The NPC also shouldn't move if the player is unable to, like walking into a wall.



Exactly that. The script I provided was just a script I had found which comes close to this, but it mirrors player movement e.g. move right, NPC goes right. Move down, NPC goes down. etc. There's no problems with how the script runs as I have done so.


What I'm looking for is similar but up/down are opposite. Like if the player moves up, the NPC moves down. If I need to make it anymore simple to understand, go to the nearest mirror you can find and move forwards, backwards, left and right while keeping it in your view. That's what I'm looking for.
It's okay, I already know what 'mirror' means.  My query was how you wanted to achieve this effect.  With your clarification, I shall move this to Script Requests, as this cannot be achieved by eventing.


Moving
There is a script made by TDS called "Move Event With Player".


That script can do what you want.
It doesn't appear to work. The script is currently at the bottom of the script list and I've input the event as such:


Fsbjr2V.png



I do recall some scripts not working unless they're put somewhere higher though, so I'll try that.


EDIT: Moving the script up seems to have fixed it but now I've run into another problem; the NPC lags behind, even with the <Match_Player_Speed> used.
It works for sure, I used it before, made many puzzles with it. Everything worked for me flawlessly.


The auto movement type should be set to "Fixed" for these events, I think. At least that's what I used for my events, and they work fine.
The NPC still lags behind. Fiddling with the <Match_Player_Speed> kind of fixes this but the NPC doesn't run seamlessly.


EDIT: The direction the NPC faces is off too. It uses the exact same spriteset as the PC but whenever they move into a wall, the NPC doesn't match the direction. The script above addresses all of these issues except for the up/down directions.
Bump.
Bump again. Still need help with this. 🙁

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-an-npc-reflect-the-player.71999/