Follow a character after a chat.
Hi I am working on script right now. where the Main Character gose up and speaks to a NPC and after the talk the NPC follows the Main Character.
Here are the Custom attributes I made.
ActorX: Real
ActorY: Real
Follow: boolean
((ActorX,ActorY is constrained to the main characters X,Y.))
Here is how I made it for the NPC.
RULE: If Follow is True
Then
RULE: When self.position.X doesn't = ActorX & self.position.Y doesn't = ActorY
Move To: ActorX, ActorY
And for the TextBox (Where the conversation is displayed.
I made the "Follow"Attribute To True to active the NPC rule.
(Ill do Sudo Code cuz if I type it it will be to much XD))
Rule: When page = 2 (means when the last page say page 2of2 is opened)
Change Attribute: Follow To True.
So After he reads the last page the NPC will follow.
So the main character finishes the conversation.
And it works!The NPC moves to the character but then after the NPC reaches the Main Characters
Position the NPC doesn't move after that. IT only gose to what ever position the Main character is and once its X,Y reaches it. It will just chill there. Dose anyone know how I can fix this or is there a better way to do this? I thought maybe its only True when the last page of the conversation is opened so maybe its being set to false again so I talked to the NPC again and go
through to the last page and the NPC wont move.
I hope you guys can understand this.
Here are the Custom attributes I made.
ActorX: Real
ActorY: Real
Follow: boolean
((ActorX,ActorY is constrained to the main characters X,Y.))
Here is how I made it for the NPC.
RULE: If Follow is True
Then
RULE: When self.position.X doesn't = ActorX & self.position.Y doesn't = ActorY
Move To: ActorX, ActorY
And for the TextBox (Where the conversation is displayed.
I made the "Follow"Attribute To True to active the NPC rule.
(Ill do Sudo Code cuz if I type it it will be to much XD))
Rule: When page = 2 (means when the last page say page 2of2 is opened)
Change Attribute: Follow To True.
So After he reads the last page the NPC will follow.
So the main character finishes the conversation.
And it works!The NPC moves to the character but then after the NPC reaches the Main Characters
Position the NPC doesn't move after that. IT only gose to what ever position the Main character is and once its X,Y reaches it. It will just chill there. Dose anyone know how I can fix this or is there a better way to do this? I thought maybe its only True when the last page of the conversation is opened so maybe its being set to false again so I talked to the NPC again and go
through to the last page and the NPC wont move.

Comments
If you are moving the MC actor away and it is on different X and Y and still no move .... I would drop a display text in the NPC to show the Follow rule to make sure it is true at all teh right times. If that all seems correct come back and post again and I'll see if I can give more ideas.
It really depends on the game. I'm not sure if it is a side scroller or open map. If you want him following at exacts or at a rubber band distance (meaning he can follow behind some or get closer)
Display Text: YOUR FALSE! Otherwise: Rule If "Follow" Is true then DisplayText:YOUR TRUE!!!
And....It worked it was false until I finished speaking to him then the NPC followed me for a second and then stopped when it reached my x,y. But If I put a Timer on him 3 seconds later he will follow me and Ill run around for abit then stop once he catches up to me and matches my x,y then He stops so the follow Kind of works still. I saw the the Display Text Stayed at YOUR TRUE! so it didn't go back to false.... I got confused after that. I thought that is whats going on but now. I don't know whats the deal.
Well the way I explained previously could work, it would work better for a side scroller.
I haven't tested this, but you could possibly try a range. Make a rule inside the NPC for when follow is true with a rule inside that says ANY self.positionX is <= game.ActorX-20 OR self.positionX is >= game.ActorX+20 OR self.positionY is <= game.ActorY-20 OR self.positionY is >= game.ActorY+20
(It would be an ANY rule)
Then
It Moves To Actor X,Y
You may need to adjust the 20's to something that fits the distance range away from your character that you will allow. This should make it so that if your character gets a certain distance from the NPC the NPC will head to his location. It should do the Move To each time because the rule should be calling it everytime one of those matches up right.
Hopefully that gets you what you are looking for
Going off your last comment. The problem is most definately Move To. Move To works up until the actor reaches the points it is supposed to Move To. Then it no longer does anything. That's why in my explanation above I put it inside of a rule that should cause him to Move To the location each time the rule meets the requirements.
Going off what you just said. That leaves me in another puzzed thought. Because if I take away the rule I have the If Follow is True. Then The NPC will follow me everywhere I go and When I stop and he matches my x,y and I move again he will still follow. I didn't get this problem until I got the rule going. Which is odd. But I am going to give it a go on what you posted earlier. Thank you!
Well I'm pretty sure Move To works all the way up until it is completed. So basically you want inside that NPC:
-Rule If Follow is true
-Rule Inside The Above Rule That tests whether the NPC is a certain distance away from the Actor (the code bit in my previous post would go here)
-The Move To inside the above testing rule.
This should make it so the NPC moves to where your actor is each time your actor moves a certain distance away from him and as long as follow is true.
If at any point you make follow not true he should stay in the last location reached.
If the NPC is already in the process of doing a move to because your actor has moved and Follow is switched to false in the process. I'm pretty sure the NPC will continue until your completes the Move To
Rule: if game.Follow is true
Then
Rule:
Attribute: self.Position.X < game.ActorX-20
Attribute: self.Position.X > game.ActorX+20
Attribute: self.Position.Y < game.ActorY-20
Attribute: self.Position.Y > game.ActorY+20
MoveTo game.ActorX, game.ActorY
Its how I made it.It seems to not be working out for me. NPC not moving now. Did I lay it out correctly
Or did I do something wrong.
Always tell your parents first.
Not a problem. Glad to help and that it worked.
FallacyStudios = He