Make a NPC follow the Player

Have any questions or problems in making your game, subscribing and/or using our software? Post here.
Forum rules
Make sure you are using the newest version. This can be downloaded at the top of the site via the "downloads" link.

Use a very good subject. "Problem" or "Help" are unacceptable titles.

Use the search feature before posting a question, as the answer is probably already here.

Subscript out of range error 9: This is a generic error, and we'll need way more information than that to figure out the problem. If you get this, strongly consider following the instructions of submitting your project through the Submit Bug feature within the editor.
User avatar
djeby
001 Enthusiast
 
Joined: Wed Jan 06, 2016 5:36 pm
Location: Romania

Make a NPC follow the Player

Postby djeby » Wed May 25, 2016 8:19 am

Hey guys,

I am trying to make a NPC to follow the player once the player talks to him.
Any idea on how to make this? I looked for an action, but did not find one predefined. Is it difficult to make? It is not a predefined route, so the NPC has to follow the player and also to follow the player between different maps. When the player exists a map and enters a new one, the NPC should follow him to the new map too.

Is that possible?
Legend of Miro - A 2D Storytelling RPG

User avatar
evs
001 Admirer
 
Joined: Tue May 08, 2012 5:27 pm
Location: Perth, Australia

Re: Make a NPC follow the Player

Postby evs » Wed May 25, 2016 9:19 am

if you want the simplest method, you could make him 'join party' and then later on 'leave party'. that would make him fight with you if you got into any battles, if not he'll just follow you around.

User avatar
djeby
001 Enthusiast
 
Joined: Wed Jan 06, 2016 5:36 pm
Location: Romania

Re: Make a NPC follow the Player

Postby djeby » Wed May 25, 2016 9:26 am

And does he follow me from one map to the other?
Legend of Miro - A 2D Storytelling RPG

User avatar
Lee
001 Support
 
Joined: Thu Sep 21, 2006 1:59 pm
Location: United Kingdom

Re: Make a NPC follow the Player

Postby Lee » Wed May 25, 2016 10:22 am

djeby wrote:And does he follow me from one map to the other?


Yes. Once a character is in your party, they'll follow the player character where ever they go.
Lee - 001 Community Manager

User avatar
djeby
001 Enthusiast
 
Joined: Wed Jan 06, 2016 5:36 pm
Location: Romania

Re: Make a NPC follow the Player

Postby djeby » Wed May 25, 2016 10:23 am

But when i add the Join party to the NPC, i can only select the main player to join or leave the party. I do not have the option to select that NPC to join the party. What am i doing wrong?
It only shows that Players can join the party, but I want a NPC character to join it.

That NPC is an actor, not a Player.

I also posted a screenshot:
Attachments
party.JPG
Actor cannot be chosen to enter a party. Only players can join the party.
Legend of Miro - A 2D Storytelling RPG

User avatar
Lee
001 Support
 
Joined: Thu Sep 21, 2006 1:59 pm
Location: United Kingdom

Re: Make a NPC follow the Player

Postby Lee » Thu May 26, 2016 8:02 am

You need to create the Actor in the "Players and Party" window (Resources menu) before it'll show up in that list.
Lee - 001 Community Manager

User avatar
djeby
001 Enthusiast
 
Joined: Wed Jan 06, 2016 5:36 pm
Location: Romania

Re: Make a NPC follow the Player

Postby djeby » Thu May 26, 2016 8:03 am

Yes, but that way it creates a new player that spawns in the same location.
How do I make it a NPC in the "Player and Party" section?
Legend of Miro - A 2D Storytelling RPG

User avatar
Lee
001 Support
 
Joined: Thu Sep 21, 2006 1:59 pm
Location: United Kingdom

Re: Make a NPC follow the Player

Postby Lee » Thu May 26, 2016 8:21 am

You need to untick the option "Currently In Party" in the Players and Party window.
Lee - 001 Community Manager

User avatar
djeby
001 Enthusiast
 
Joined: Wed Jan 06, 2016 5:36 pm
Location: Romania

Re: Make a NPC follow the Player

Postby djeby » Thu May 26, 2016 8:31 am

And what do I add in the Player field? It is default to Player 1 for the created NPC.
Legend of Miro - A 2D Storytelling RPG

User avatar
evs
001 Admirer
 
Joined: Tue May 08, 2012 5:27 pm
Location: Perth, Australia

Re: Make a NPC follow the Player

Postby evs » Thu May 26, 2016 8:36 am

hey mate, i just had a go at making the non party NPC follow across a map border. it worked using an actor variable. oh i cant upload the video i made :( ok, heres how it went:
Create Your NPC, give him/her an 'Actor Variable' called 'Following' and set its default value to 'No'.
then go into his 'talked to/activated' trigger and put (after any conversation you want to add) 'Actor variable operation'-(Actor This) set the variable 'Following' to 'Yes'.
Also now 'change Automatic movement style' check "move' and 'Face' and 'Towards Player'
-now he will follow you after you talk to him.

after that if you use a zone along the edge of your map, within the zones trigger 'Collided with actor -Player' put 'position actor' select main and while holding ctrl also select your NPC Actor. then set the target position to the next map. so when you hit the zone later, it will take you both to the next map, and he will still be following you.

oh heres a video if you find that easier to follow. im not sure how to embed it

https://youtu.be/aCCGII0D8zU

User avatar
djeby
001 Enthusiast
 
Joined: Wed Jan 06, 2016 5:36 pm
Location: Romania

Re: Make a NPC follow the Player

Postby djeby » Thu May 26, 2016 11:37 am

Thanks, I will try it out.
Yours seems to work.
Legend of Miro - A 2D Storytelling RPG

User avatar
SBG
001 Subscriber
 
Joined: Thu Jun 17, 2010 8:37 pm
Location: merca

Re: Make a NPC follow the Player

Postby SBG » Thu May 26, 2016 10:13 pm

Nice simple way to implement it. Just so you know, the script you put in the zone will position the NPC on the other map regardless if he's following you or not without some sort of follower check.

User avatar
evs
001 Admirer
 
Joined: Tue May 08, 2012 5:27 pm
Location: Perth, Australia

Re: Make a NPC follow the Player

Postby evs » Fri May 27, 2016 7:53 am

good point


so in the zone a comparison branch should be added to the top of the script check if the NPCs Actor Variable 'Following' is Yes or No
Last edited by evs on Fri May 27, 2016 7:55 am, edited 1 time in total.
Reason: Automatically merged double post.

User avatar
CnN
001 Subscriber
 
Joined: Tue May 24, 2016 12:29 am

Archived

Postby CnN » Fri May 27, 2016 12:47 pm

Archived
Last edited by CnN on Tue Jun 06, 2017 4:31 pm, edited 4 times in total.

User avatar
SBG
001 Subscriber
 
Joined: Thu Jun 17, 2010 8:37 pm
Location: merca

Re: Make a NPC follow the Player

Postby SBG » Fri May 27, 2016 5:16 pm

I would only make them party members if you want them to behave like party members, which definitely can complicate things if you're not careful(let's say you've already scripted your player interactions as P0 instead of the party, or you're using the default party menu to display info about the player, and only want one character).

evs's method isn't so much a workaround as it is a straightforward way to get NPCs to follow the main actor.

But it's all about what you want to do. Party members are the obvious choice if you want to be able to add, remove and switch between playable characters. If you just want a simple AI follower, I'd suggest evs's method so you don't have to do all of that party scripting. The thing I hate most about party members is they have to be created beforehand, then removed at the start and scripted back in. And you're limited to whatever party members you add in the first place. If you're making a game with tons of followers, especially randomly generated NPCs, party members are out of the question.

User avatar
djeby
001 Enthusiast
 
Joined: Wed Jan 06, 2016 5:36 pm
Location: Romania

Re: Make a NPC follow the Player

Postby djeby » Sat May 28, 2016 5:45 am

Thanks, I just needed the NPC to follow me and continue a dialogue in a certain place. Crossing multiple maps...
I managed to do that, thanks.

There was an issue with the Walk towards player in my game for some reason. The NPC would only come once towards the player, then I would have to talk to him again in order to follow me once more, and so on.
Legend of Miro - A 2D Storytelling RPG

User avatar
evs
001 Admirer
 
Joined: Tue May 08, 2012 5:27 pm
Location: Perth, Australia

Re: Make a NPC follow the Player

Postby evs » Sat May 28, 2016 6:49 am

well im glad you got it working, im not sure what the problem is with it now,, that sounds less than ideal... because you know to talk to him again, but other players wont neccesarily know. maybe someone will have an idea. which action did you use? change automatic movement style?

User avatar
SBG
001 Subscriber
 
Joined: Thu Jun 17, 2010 8:37 pm
Location: merca

Re: Make a NPC follow the Player

Postby SBG » Sat May 28, 2016 2:23 pm

Put the script in a while/timer trigger in the actor. Mouse down to change the actor variable, and the while timer checks the variable and activates the scripts depending on it.

Galaxy Games
Member
 
Joined: Thu Aug 25, 2016 8:02 pm

She can't keep up..lol

Postby Galaxy Games » Sat Sep 03, 2016 10:26 pm

Using Ev's method: How would you get this NPC to follow you through multiple zones?


Hey Guys,
Ive tried getting an NPC to follow me across maps using Ev's method, but she will only follow me to the next map. On that next map, she is no longer available in the zones.
Last edited by Galaxy Games on Sat Sep 03, 2016 10:30 pm, edited 1 time in total.
Reason: Automatically merged double post.

User avatar
evs
001 Admirer
 
Joined: Tue May 08, 2012 5:27 pm
Location: Perth, Australia

Re: Make a NPC follow the Player

Postby evs » Sun Sep 04, 2016 9:55 pm

yeah this is not something iv used in one of my games.. i think you would have to set up any and all zones that you want to use like the first one. if the secondary actor is not available to select because shes not in the current map, you can search other maps and select her

Galaxy Games
Member
 
Joined: Thu Aug 25, 2016 8:02 pm

Re: Make a NPC follow the Player

Postby Galaxy Games » Wed Sep 07, 2016 9:51 pm

Thanks Evs, it worked like a charm. Only problem now is, when she meets her demise, she shows up dead on every map I enabled her in. Any advice?

User avatar
evs
001 Admirer
 
Joined: Tue May 08, 2012 5:27 pm
Location: Perth, Australia

Re: Make a NPC follow the Player

Postby evs » Tue Sep 27, 2016 10:37 pm

i make dead monsters/people dissapear after a few seconds personally. in a trigger called 'died/defeated' (or something similar) in the actor or actor template. (Delay 3 Seconds, actor change existence<non existent>) you can toggle existence back and forward a few times with a small delay for an oldschool arcade feel if that suits your game, or even fade them out.


Return to Technical Support Questions

Who is online

Users browsing this forum: No registered users

cron