Following Character

Started by metalmario991, Wed 29/07/2015 00:51:29

Previous topic - Next topic

metalmario991

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?

Slasher


1: check out FollowCharacter in the help menu

eg
Code: ags

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.



Khris

To use the side character on stuff, just implement them as inventory item and use them like a regular one.

metalmario991

What does eagerness mean? Also how will calling look in the script

Khris

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:

Code: ags
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);
}

metalmario991

When I program a character to follow another how do I get that character to stop following?

Gilbert

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.

SMF spam blocked by CleanTalk