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>".
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>".