Weaving feature for pathfinding?

I just started using A* (and loving it!) but it seems the shortest path is always calculated. That makes sense, but in the natural world creatures often deviate from the shortest path. Could there be a feature to incorporate a degree of weaving or straying from the path? There could be some sort of noise function (perhaps the user could choose what kind of noise) which would modify the shortest path (to a degree chosen by the user) how much weaving or straying occurs. The resulting path would be more winding. I’m not sure if others would find use in this, I just think it would make NPC creatures behave more naturally.

So natively I don’t think there’s a sorta “humanization” option. However this is totally possible with something like a custom modifier. I’ve actually done something similar to this in my own project- what I did was kinda silly in retrospect because I could’ve done this in a custom modifier… but I was new to Astar then so I didn’t know any better :sweat_smile:

I basically set the agent’s destination to be offset from the target’s actual position, based on how far it was from the target. So if a unit was far away, it’ll try walking to some place pretty far perpendicular to it and the target. This is naturally self correcting though, as that new perpendicular destination actually placed it closer to the real target, meaning the new perpendicular target was closer to the real target. As that keeps happening it creates some actually super convincing natural movement- I’d have up to like 200 units weaving into each other and around obstacles trying to get to the player and it worked phenomenally.

I’ll have to write this into a modifier at some point that anyone can use :smiley:

Hi

In addition to what @tealtxgr said, here’s a code sample for accomplishing a similar thing with the FollowerEntity: FollowerEntity - A* Pathfinding Project

Thanks guys, that’s awesome!