Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Simple "Follow Me" script

Haiiiiiii! Okay, I hope I'm not a bother here, but I'm TOTALLY new to RGSS and I'm itching to learn. I tried making a "follow me" script in the built-in edit event thingy, and it went pretty well. Here's how I set it up:

Code:
 

@>Conditional Branch: The X button is being pressed

  @>Conditional Branch: The Right button is being pressed

     @>Set Move Route: Player

       :                      :$>Change Freq: 4

       :                      :$>Change Speed: 4

     @>Set Move Route: This event (Repeat Action, Ignore If Can't Move)

       :                      :$>Change Speed: 4

       :                      :$>Change Freq: 4

       :                      :$>Move toward Player

     @>

  : Branch End

  @>Conditional Branch: The Down button is being pressed

     @>Set Move Route: Player

       :                      :$>Change Freq: 4

       :                      :$>Change Speed: 4

     @>Set Move Route: This event (Repeat Action, Ignore If Can't Move)

       :                      :$>Change Speed: 4

       :                      :$>Change Freq: 4

       :                      :$>Move toward Player

     @>

  : Branch End

  @>Conditional Branch: The Left button is being pressed

     @>Set Move Route: Player

       :                      :$>Change Freq: 4

       :                      :$>Change Speed: 4

     @>Set Move Route: This event (Repeat Action, Ignore If Can't Move)

       :                      :$>Change Speed: 4

       :                      :$>Change Freq: 4

       :                      :$>Move toward Player

     @>

  : Branch End

  @>Conditional Branch: The Up button is being pressed

     @>Set Move Route: Player

       :                      :$>Change Freq: 4

       :                      :$>Change Speed: 4

     @>Set Move Route: This event (Repeat Action, Ignore If Can't Move)

       :                      :$>Change Speed: 4

       :                      :$>Change Freq: 4

       :                      :$>Move toward Player

     @>

  : Branch End

: Else

  @>Conditional Branch: The Right button is being pressed

     @>Set Move Route: Player

       :                      :$>Change Freq: 3

       :                      :$>Change Speed: 3

     @>Set Move Route: This event (Repeat Action, Ignore If Can't Move)

       :                      :$>Change Speed: 3

       :                      :$>Change Freq: 3

       :                      :$>Move toward Player

     @>

  : Branch End

  @>Conditional Branch: The Down button is being pressed

     @>Set Move Route: Player

       :                      :$>Change Freq: 3

       :                      :$>Change Speed: 3

     @>Set Move Route: This event (Repeat Action, Ignore If Can't Move)

       :                      :$>Change Speed: 3

       :                      :$>Change Freq: 3

       :                      :$>Move toward Player

     @>

  : Branch End

  @>Conditional Branch: The Left button is being pressed

     @>Set Move Route: Player

       :                      :$>Change Freq: 3

       :                      :$>Change Speed: 3

     @>Set Move Route: This event (Repeat Action, Ignore If Can't Move)

       :                      :$>Change Speed: 3

       :                      :$>Change Freq: 3

       :                      :$>Move toward Player

     @>

  : Branch End

  @>Conditional Branch: The Up button is being pressed

     @>Set Move Route: Player

       :                      :$>Change Freq: 3

       :                      :$>Change Speed: 3

     @>Set Move Route: This event (Repeat Action, Ignore If Can't Move)

       :                      :$>Change Speed: 3

       :                      :$>Change Freq: 3

       :                      :$>Move toward Player

     @>

  : Branch End

  @>

: Branch End

@>Conditional Branch: The Y button is being pressed

  @>Text: Sonya: We have to cut down these

   :        : fiends first!

  @>Conditional Branch: Switch [0002: First_battle] == OFF

     @>Text: Sonya: Find one and I'll show you how

      :        : to fight!

     @>

    : Branch End

  @>

:Branch End

@>

#This event was set to "parallel process" as a trigger.

 

And the explanation:
This is a basic "follow me" script that I wrote with rpgxp event editor. It features a "running" portion and it also features an "ask me" portion. The script basically says to "increase speed and frequency while button X is being pressed, all the while moving wherever the player's current position is." So, both the player and the event this script is assigned to change speed and frequency at the same time depending on whether button X is being pressed. And the "repeat movement" is there to make sure that the event is ALWAYS near the player. The last portion of the script "ask me" is a little extra thing I added that whenever button Y is pressed, you can "talk" to your partner, the one following you. The switch is there to determine whether or not your first battle was encountered and you have undergone the tutorial.

Now, it LOOKS like I have everything figured out already, but that is false. ^^ Actually, this little gizmo I made is quite buggy... the sprite DOES follow the player, but it often gets in the player's way. You can copy this script into the event editor of your own test game and you'll see what I mean. Well, seeing how I'm learning RGSS, I would like to start out with a simple "follow me" script written in RGSS. But, I don't know how ^^;. Could someone show me how I would do that? I'm totally new to the language and... it would help if I knew which parts of the script does what and why. I suppose I'm asking for too much there but thought it was worth asking! Thanks in advance!
 
I guess the main problem is that noone feels like recreating your event stuff just to get a non-working thing... supplying a demo might work better for you on that matter.

That being said, what you're trying to do is mostly referred to as 'caterpillar' script within the RM community. If you're looking for that, you should easily see how they're set up. It's nothing exhaustive to script, but it does go through some classes, so yeah... just have a look at some.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top