Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: metalmario991 on Wed 29/07/2015 00:51:29

Title: Following Character
Post by: metalmario991 on Wed 29/07/2015 00:51:29
In my game I want to do something like "Ben there, Dan that" and have a character that follows you around and you use to interact in certain puzzles. What I need to know are two things:
1) If I have the side character follow the main character how is that programmed?
2) When I use the side character icon to interact, do I use the User Modes 1 and 2 on objects? If so, how does that work?
Title: Re: Following Character
Post by: Slasher on Wed 29/07/2015 08:40:29

1: check out FollowCharacter in the help menu

eg
Code (ags) Select

cMan.FollowCharacter(cEgo, 5, 80); // character to follow, distance, eagerness


2: You can use interactions to side player (npc) in its property panel and you can ever set it as main character.
You can click on an object / hotspot and get npc to do things by 'calling' him in the script.

hope this helps.


Title: Re: Following Character
Post by: Khris on Wed 29/07/2015 10:32:20
To use the side character on stuff, just implement them as inventory item and use them like a regular one.
Title: Re: Following Character
Post by: metalmario991 on Thu 30/07/2015 01:31:44
What does eagerness mean? Also how will calling look in the script
Title: Re: Following Character
Post by: Khris on Thu 30/07/2015 10:19:52
The parameters are explained in the manual, which is the very first resource you should exhaust before coming here.

"Calling him" in the script will look something like this:

function hStove_Useinv() {

  if (player.ActiveInventory == iSidekick) {
    cSidekick.Walk(123, 45, eBlock);
    cSidekick.FaceLocation(cSidekick.x, cSidekick.y - 1); // up
    Wait(20);
    cSidekick.FaceLocation(player.x, player.y);
    Wait(5);
    cSidekick.Say("It's hot; what am I supposed to do, burn myself?");
  }
  else unhandled_event(1, 3);
}
Title: Re: Following Character
Post by: metalmario991 on Thu 06/08/2015 01:14:20
When I program a character to follow another how do I get that character to stop following?
Title: Re: Following Character
Post by: Gilbert on Thu 06/08/2015 06:08:19
They're all in the manual.
QuotePass CHARTOFOLLOW as null to stop the character following.
So, just use cMan.FollowCharacter(null); to stop say, the character cMan to follow any other character.