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 ;)
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
I agree with Trent R.
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
From manual entry of FollowCharacter():
Quote
Pass CHARTOFOLLOW as null to stop the character following.
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.
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.