P
ph101
Guest
Hiya
I'm looking for suggestions for natural looking pathfinding for multiple NPCs. Say a crowd of zombies (they aren't zombies) but that type of thing. The point is they go between different points on the grid in crowds - they aren't pursuing a player or anything.
Here's what I'm doing: I have sometimes dozens or more NPC agents calculating paths (using if mp_grid_path) between variable waypoints. They don't all calculate their paths at the same time, in fact one at a time and wait until no one else is so that there is no terrible lag. The nav grid has purely the walls added to it.
Because I want the AI agents to have a natural looking swarming type movement, and to bump off each other, they dont strictly follow the path using path_start, but use mp_potential_step (avoiding a parent object including walls and other AI agents) to walk towards a point on the path a set number of points ahead (path_get_point_x, path_get_point_y). When within a small distance of that point, they choose to move to the next point in the path (usually 5 points further along the point - can be a random amount, but the further it is, the less accurate their behaviour in term sof say going round corners).
This results in some nice natural looking crowding around behaviour, and i have to say potential step is just a great function as is the pathfinding, but I have some problems:
1. Agents coming the opposite way between waypoints are attempting to follow same path and so you get a grid lock in the middle as they all attempt to follow the trail of points at same location. Possibly I could periodically add the agent instances to the grid (this cant be dont all the time because of CPU but maybe every few seconds so they avoid a snap shot of busy locations?).
2. I want to give them more natural looking behaviour, with more variance. This would help 1). Is there a nice easy way to make them stray more from their path more or make a more varied path? I tried adding smoother paths but it is not pronounced enough to make much of a difference. All I can think of to take their next point to step towards and randomly relocate to a nearby point - but would require testing if the place is empty in the grid first so lots of CPU. Maybe would only happen sporadically?
3. Another issue is that when there are many of them bunching up to reach their next point they sometimes get pushed beyond their waypoint etc and so need to go back to reach it and trigger then next point to move towards.
Would be great to have some general thoughts on this, if you have ever done similar.
Thanks
I'm looking for suggestions for natural looking pathfinding for multiple NPCs. Say a crowd of zombies (they aren't zombies) but that type of thing. The point is they go between different points on the grid in crowds - they aren't pursuing a player or anything.
Here's what I'm doing: I have sometimes dozens or more NPC agents calculating paths (using if mp_grid_path) between variable waypoints. They don't all calculate their paths at the same time, in fact one at a time and wait until no one else is so that there is no terrible lag. The nav grid has purely the walls added to it.
Because I want the AI agents to have a natural looking swarming type movement, and to bump off each other, they dont strictly follow the path using path_start, but use mp_potential_step (avoiding a parent object including walls and other AI agents) to walk towards a point on the path a set number of points ahead (path_get_point_x, path_get_point_y). When within a small distance of that point, they choose to move to the next point in the path (usually 5 points further along the point - can be a random amount, but the further it is, the less accurate their behaviour in term sof say going round corners).
This results in some nice natural looking crowding around behaviour, and i have to say potential step is just a great function as is the pathfinding, but I have some problems:
1. Agents coming the opposite way between waypoints are attempting to follow same path and so you get a grid lock in the middle as they all attempt to follow the trail of points at same location. Possibly I could periodically add the agent instances to the grid (this cant be dont all the time because of CPU but maybe every few seconds so they avoid a snap shot of busy locations?).
2. I want to give them more natural looking behaviour, with more variance. This would help 1). Is there a nice easy way to make them stray more from their path more or make a more varied path? I tried adding smoother paths but it is not pronounced enough to make much of a difference. All I can think of to take their next point to step towards and randomly relocate to a nearby point - but would require testing if the place is empty in the grid first so lots of CPU. Maybe would only happen sporadically?
3. Another issue is that when there are many of them bunching up to reach their next point they sometimes get pushed beyond their waypoint etc and so need to go back to reach it and trigger then next point to move towards.
Would be great to have some general thoughts on this, if you have ever done similar.
Thanks