Need help with character move

Started by Jakerpot, Sun 15/03/2009 01:50:03

Previous topic - Next topic

Jakerpot

Hi Folks! I need to make my npc character walk toward the player, wherever he is, so i used something like:
Code: ags


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 ;)



Trent R

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
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Swordwielder


Jakerpot

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



Gilbert

From manual entry of FollowCharacter():
Quote
Pass CHARTOFOLLOW as null to stop the character following.

Jakerpot

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.



Ishmael

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.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

SMF spam blocked by CleanTalk