Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Jakerpot on Sun 15/03/2009 01:50:03

Title: Need help with character move
Post by: Jakerpot on Sun 15/03/2009 01:50:03
Hi Folks! I need to make my npc character walk toward the player, wherever he is, so i used something like:


cNPC.Walk(cPlayer.x, cPLayer.y); (Not the exactly code, it works perfectly)



but then the npc moves EXACTLY to the position of the player, and this feels weird, so i want him to stay in front of, not on, the character. How can i do this? I thought in making this way

int player.x
int player.y

and then remove a little (5 or 7) from it before moving, but if the player is on a egde?
i'm unsure, please help me ;)
Title: Re: Need help with character move
Post by: Trent R on Sun 15/03/2009 02:27:35
cPlayer.x+10 will put it 10 pixels to the right.

And though I've never used the FollowCharacter, I think that's what you're looking for.


~Trent
Title: Re: Need help with character move
Post by: Swordwielder on Sun 15/03/2009 03:06:46
I agree with Trent R.
Title: Re: Need help with character move
Post by: Jakerpot on Sun 15/03/2009 14:55:29
If i use follow character, can i make him stop folowing him? (Yes, much n00bie question, of course it has your jackass! But how i can use it please?)

I think it's better i make a condition, if is character on the hotspot (on the edge) turn is on left/right edge true, and then when the npc follow my character, if it is on left, + 10 pixels, if it is on the right, - 10 pixels, i think it's a good idea huh?  ;D
Title: Re: Need help with character move
Post by: Gilbert on Sun 15/03/2009 15:49:13
From manual entry of FollowCharacter():
Quote
Pass CHARTOFOLLOW as null to stop the character following.
Title: Re: Need help with character move
Post by: Jakerpot on Mon 16/03/2009 23:51:38
ok, thank you  :) but i want to know how can i make when the npc followed the player, how can i know that the npc is standing in front of the player? Is there a eBlock or something like that??? thanks.
Title: Re: Need help with character move
Post by: Ishmael on Thu 19/03/2009 18:43:58
You can use player.loop to find out which way the player is facing, or use .FaceCharacter or .FaceLocation to make the player turn. There's also a GetWalkableAreaAt function you can use to see if there is walkable area infront of the player (after finding out which way he is facing) and react accordingly, if you want.