Status
Not open for further replies.

Adellie

NPC
Veteran
Joined
May 4, 2014
Messages
340
Reaction score
481
Primarily Uses
Hey guys,

I'm trying to make a sort of ghost npc to imitate the player's movement.

Through eventing, I can get npcs to move in the same direction as me, but it isn't quite a mirror. (They are just parallel processes that wait on arrow key presses and then take a movement route accordingly.) From top to bottom:

  1. The actual player.
  2. Event that waits until movement finishes. (Normal speed, high frequency) The npc's speed doesn't match mine very well and the walk cycle looks a little clunky regardless of settings.
  3. Event that moves without waiting. (Normal speed, normal frequency) It appears to match my speed better. Then I realized that the npc always moves 1 extra tile.
wu0754.jpg


Side note, I don't need the movement to match perfectly, but I'd like it if the ghost/clone could take a few steps without being obviously off.

Any ideas/feedback would be highly appreciated. Thanks in advance. :)
 
Last edited by a moderator:

Imploded Tomato

Veteran
Veteran
Joined
Sep 16, 2012
Messages
161
Reaction score
56
First Language
English
Primarily Uses
"Ghost npc to imitate the player's movement." That's an interesting idea! Never tried that myself. Are you just using the default scripts? I'm sure there are multiple ways of doing this using a movement script, but it could be complicated and require modifiying script integers. By default, I believe the player character's movement values are defined somewhere in the RGSS3 script, seems to be slightly faster than you need it to be, although I'm not sure where it is located... It is possible to change the defualt player speed and frequency within the default scripts, or you can find a custom script as well.
 
Last edited by a moderator:

boldpaste2

The Dragon Heretics
Veteran
Joined
Dec 7, 2013
Messages
797
Reaction score
439
First Language
English
Primarily Uses
I have tried to do something like this and found that events and the "Actor" are on totally separate methods. With the parallel processes, they wait for user interaction but it has to run down the the entire event page to see it (which causes the delay your image is producing). I found what works is to have the events check player position and move accordingly. There will still be a slight delay but it will be more accurate as it's calculating movements based on math rather then button presses.

For example,

If you have a player at 80, 80 and moves to 80, 81

and

If you have an event at 80, 83 Once the player moves to 81, you make it so that the event moves to 84.

(this is easier said then done however.)

Another method you could try that might be a bit less intimidating is to simpley hide the actor and have the player think that the event is the actor though if you have a map larger then your screen size it might be a bit difficult to track the camera movement.

The only other way you can do this to have it exact would be through  a script unfortunately.
 
Last edited by a moderator:

FenixFyreX

Fire Deity
Veteran
Joined
Mar 1, 2012
Messages
434
Reaction score
311
First Language
English
Primarily Uses
Here's one to try out:

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 endendJust add a comment to the specific page of the event you want to mimic the player's movement: <move_with_player>If you dash, the event will dash with you as well, and if you are playing from the editor and use CTRL to go through walls, the event will follow as well. Is this satisfactory?
 
Last edited by a moderator:

Adellie

NPC
Veteran
Joined
May 4, 2014
Messages
340
Reaction score
481
Primarily Uses
Yes, It's perfect!!

I wasn't expecting to get a solution so quickly, and you even included dashing which i didn't mention.

Thanks so much for taking the time FenixFyreX.  :wub:

--

@boldpaste2: Thanks for posting some ideas! I did think about hiding the player and making a psuedo-player, but like you mentioned the camera doesn't follow the dummy. Other concerns i had thought of were caterpillar followers, and dashing with shift.
 

boldpaste2

The Dragon Heretics
Veteran
Joined
Dec 7, 2013
Messages
797
Reaction score
439
First Language
English
Primarily Uses
It's great that you found a solution :D

I am going to actually bookmark this page because Fenix's script could have saved me in several situations. ^^
 

Aramis-IX

Villager
Member
Joined
Sep 23, 2014
Messages
15
Reaction score
23
First Language
English
Primarily Uses
Here's one to try out:

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 endendJust add a comment to the specific page of the event you want to mimic the player's movement: <move_with_player>If you dash, the event will dash with you as well, and if you are playing from the editor and use CTRL to go through walls, the event will follow as well. Is this satisfactory?
Hey FenixFyreX. Is it possible to make this script 8-direction compatible? I've been messing around with it and can't get it to work as of yet... I'm using Hime's Eight-Directional Movement script.
 

Aramis-IX

Villager
Member
Joined
Sep 23, 2014
Messages
15
Reaction score
23
First Language
English
Primarily Uses
Nevermind... I figured it out!
 

BCj

Veteran
Veteran
Joined
Jun 19, 2014
Messages
1,864
Reaction score
1,075
First Language
Dutch
Primarily Uses
N/A
This is a necro but, any chance of someone fixing the script with the correct lay-out?

Here's one to try out:

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 endendJust add a comment to the specific page of the event you want to mimic the player's movement: <move_with_player>If you dash, the event will dash with you as well, and if you are playing from the editor and use CTRL to go through walls, the event will follow as well. Is this satisfactory?
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
695
Reaction score
451
First Language
English
Primarily Uses
RMVXA
@BCj
Ruby:
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
 
  • Like
Reactions: BCj

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,930
Reaction score
1,023
First Language
English
Primarily Uses
RMVXA
Try this
Ruby:
# FenixFyreX
# Just add a comment to the specific page of the event you want
# to mimic the player's movement: <move_with_player>If you dash,
# the event will dash with you as well, and if you are playing
# from the editor and use CTRL to go through walls, the event
# will follow as well. Is this satisfactory?

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
Well see what happens when you don't refresh the page for a while.
*ninja'd
 
  • Like
Reactions: BCj
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

jeetje, you are told to read forums and learn about them before you post, cmon ppl, it is impossible?
plugin for this, plugin for that, i should probs just buy all the visustella plugins lol
Hey you know that problem I had with my old project file? I figured out what went wrong, so I fixed it there! Now I don't need this new file! *deletes*

......

*remembers I made good changes on it and did not write those changes down elsewhere*

.....Well ****.
Why won't you play above 10 fps game. you were working fine yesterday
pkJASCkjl;n

Forum statistics

Threads
121,520
Messages
1,142,248
Members
159,683
Latest member
RiyanTheConfused
Top