NPC walks in non-walkable area

Started by doctorhibert, Wed 22/02/2017 22:42:48

Previous topic - Next topic

doctorhibert

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?

Kumpel

#1
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.

GoodGuy

#2
Your trouble is in a Walkwhere optional parameter.
Code: ags
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
cEgo.Walk(155, 122, eBlock, eWalkableAreas);

doctorhibert

Thank you, I was able to fix it

SMF spam blocked by CleanTalk