Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: maraki_ang3l on Thu 11/06/2009 15:13:16

Title: Follow Character still appearing
Post by: maraki_ang3l on Thu 11/06/2009 15:13:16
I have a character who is following my main character but in some rooms i don't want to follow me.What would you suggest me to do?

I have a glocal variable and if that is 1 then he follows me and i put it in the fuction rep_ex  but even if I don;t put that if in the rooms that i don't want to appear the second character,he appears   :o

Any suggestions?
Title: Re: Follow Character still appearing
Post by: GuyAwesome on Thu 11/06/2009 15:30:23
What're you doing with that variable?
If you want to stop a character following your player, just call cNPC.FollowCharacter(null); , as it says in the manual. To restart them following, re-call cNPC.FollowCharacter(player). (With the right name for the other character, obviously...)

If you're going to be doing that a few times, you could probably set up some functions to save you having to repeat the code every time - not that it's really THAT much code.
Title: Re: Follow Character still appearing
Post by: Trent R on Thu 11/06/2009 16:00:19
Put the lines Guy has pointed out in the room_leave scripts of the last rooms that are 'followable'.

For example, say a wolf is following Little Red Riding Hood through the woods. Once she gets inside the house, she won't be followed anymore. So in the room outside the house, put cWolf.FollowCharacter(null) in the room_leave script. You may also want to put a cWolf.FollowCharacer(player) in the room_afterfadein so that when you come back to the room.....


If you have to do this with a large number of rooms, I suggest reading up on Custom Properties and the on_event function. It's not hard scripting, but we're here to answer questions you may have about it.



~Trent