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.

Help? Event follow Player

hey, I'd like to request a tutorial on getting an NPC/event to follow you. you know, it will follow behind you on each step. I might be too specific in saying making it so the character CANT walk through the event? if it's too specific make it so you can walk through it.
 
Ok, i got it to not walk through me, but I need it so when it's next to me it stops. also, i found it was too slow with speed and freq on 4, so i put the freq to 6, and it keeps walking around me and all over the place. if i put if back to 5 or 4, it doesnt walk at the same pace my character does.
 
It's one of the cases where scripts are the simple solution.
From my own experience, getting NPC to follow the player using events is a hassle. You can set it to 'move player left', 'move EV006:NPC left', etc, etc, or use the Approach, which makes NPCs run around like they're on Extasy.

Or, you can use a caterpillar script. I use Zeriab's, which can be turned ON and OFF by pulling a switch.
Simply make an event in the map of the cutscene, for the 2nd party member. Name it \cat_actor, where i is the id of the 2nd actor. That way only he follows you. Change his sprite(Change actor graphic) to whatever you need, until the cutscene is over.
Then, it's a simple process: turn the switch ON, make the cutscene, and turn the switch off.

It may seem like an overkill, but it's only: turn caterpillar ON, do the cutcene, turn switch OFF. If you do this, don't use my ADD-ON for the script.
 
Yes, it shouldn't be a problem.
I double checked, and all you need to do is make an event named \cat_actor[id] and give it the graphic of the following NPC:
followplayerwithzeriabscript2.jpg



Use the id of an actor which you know is in the party. finally, find this line in the script:
event.character_name = actor.character_name
and add a # sign before it, to disable it. The line should turn green.
Then, when the switch is ON, that NPC will follow, and when OFF, it'll stand on the map, and work like any event, with the commands you placed in it.
 
ok. it would work, but for some reason I have an error with the caterpillar script. It says: "Script 'Caterpillar Script' line 417: SyntaxError occured.". I went and checked that line, and all that was on that line was 'return result' (no quotations). What's wrong with it?
 
I'm not sure.. I couldn't get your error, with and without the SDK.
-Are you using other scripts that handle the party (big party, etc)?

If not, you're doing something wrong.
-Did you change the line like I said? it should be:
#event.character_name = actor.character_name
-Did you place the caterpillar script below the other scripts, in a new page above Main?
 
Oh, I fixed it. for some reason, some parts of the script were missing :huh:
I ran it and got an error.
---------------------------
Pokemon Fusion
---------------------------
Exception: NoMethodError

Message: undefined method `[]' for nil:NilClass

Caterpillar Script:288:in `check_caterpillar'

Caterpillar Script:105:in `refresh'

Caterpillar Script:103:in `each'

Caterpillar Script:103:in `refresh'

Caterpillar Script:392:in `[]='

Interpreter:946:in `command_121'

Interpreter:944:in `each'

Interpreter:944:in `command_121'

Interpreter:342:in `execute_command'

Interpreter:190:in `update'



This exception was logged in errorlog.txt.

Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK
---------------------------

might this be becuase the event I have of the person is an autorun, which turns the switch called Cat Switch on straight away?
 
No. It seems like $data_actors isn't defined yet, which makes no sense. It's created in the title screen before the game starts. Even if you have a script to skip the title screen, this should not happen.
Are you sure the error is at the line which reads:
if $data_actors[@caterpillar_actor].nil?

If so, try adding this before line 288.
[rgss]if $data_actors.nil?
$data_actors        = load_data("Data/Actors.rxdata")
end
[/rgss]

If not, please post the correct line. (your cursor should appear on it in the scripts window, after the error happens.)

I still think it's 2 scripts conflicting, though.
 
It mgiht be. And you were right, if $data_actors[@caterpllar_actor].nil? was one of the errors. I put the lines in you said to put in and got this:

Exception: NoMethodError

Message: undefined method `actors' for nil:NilClass
Caterpillar Script:57:in `add_actor'
Caterpillar Script:294:in `check_caterpillar'
Caterpillar Script:105:in `refresh'
Caterpillar Script:103:in `each'
Caterpillar Script:103:in `refresh'
Caterpillar Script:395:in `[]='
Interpreter:946:in `command_121'
Interpreter:944:in `each'
Interpreter:944:in `command_121'
Interpreter:342:in `execute_command'
 
Once again, people are jumping to scripts where it is not needed... Do the same as you were starting out with, except do;

:Turn Toward Player
:One Step Forward

Make sure to check "Ignore if can't be done".
 
@BrunoTR
Interesting. It works better than anything I've tried before. Still, it's not as smooth as a caterpillar script, and the walking speed is always too fast or too slow.
@Vendix
Even if you don't use this caterpillar script, you'll still get errors. I mean, If you reach the first map without creating $data_actors and $game_party, you have a problem with some other scripts.
Unless you're using RMVX and forgot to mention it :x
 

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