Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: doctorhibert on Wed 22/02/2017 22:42:48

Title: NPC walks in non-walkable area
Post by: doctorhibert on Wed 22/02/2017 22:42:48
So in my game there's a point when an NPC walks from offscreen to where the player is, but for some reason it's not following the walkable areas I set up, it's just going straight for the player and in front of things the characters aren't supposed to walk on. How do I fix this?
Title: Re: NPC walks in non-walkable area
Post by: Kumpel on Wed 22/02/2017 23:06:59
As your char comes from offscreen you need to set your char.walk to walk "anywhere" first (as you did, right?). But this ignores all blocked areas as well as all nonwalkables. So you need to bring him to the beginning of the walkablearea and then do a new Char.walk command with your target coordinates and the "WalkableAreas" variable activated as soon as the char is on the area.
Title: Re: NPC walks in non-walkable area
Post by: GoodGuy on Fri 24/02/2017 12:09:03
Your trouble is in a Walkwhere optional parameter.
Code (ags) Select
Character.Walk(int x, int y, optional BlockingStyle, optional WalkWhere);
Explanation
QuoteIf walkWhere is eWalkableAreas (the default), then the character will attempt to get as close a possible to (X,Y) by using the room's walkable areas.
If walkWhere is eAnywhere, then the character will simply walk directly from its current location to (X,Y), ignoring the room walkable areas.
Right example
Code (ags) Select
cEgo.Walk(155, 122, eBlock, eWalkableAreas);
Title: Re: NPC walks in non-walkable area
Post by: doctorhibert on Fri 24/02/2017 19:09:56
Thank you, I was able to fix it