End of my attempt creating a lazy local avoidance algorithm


After trying for 2 weeks I think this is the best I can get out of my naive path-finding algorithm. The current implementation is based on the idea of force vector: each colliding agent puts a force onto the other agent as well as feeling the force from the other, and aside from their forward movement, which is just moving towards the current target, they also move to left and right based on the force from colliding agents. In my previous attempts, when the force is applied to all directions, it causes severe oscillation that just breaks the visuals.

Other methods I have tried includes rigidbody and rotation. The former one is just attach rigidbodies to each agent and let them push themselves around: this method is kind of working in 3D, but  in 2D it's just a lot of oscillation and pointless moving; it's also result of using too many agents to surround a target. The latter method is sort of working and it looked somewhere similar to StarCraft2, which game I was trying to copy from in terms of path-finding algorithm. However, it creates deadlocks too often: when there's are a lot of agents, most of them will be totally not movable until everything around it is gone.

The current method is also not really desirable, as agents moving to the target almost always collide into the same point first, then translate horizontally to move away from each other: when there are a lot of units, it's causing a lot of oscillation in the form of rotating backwards and move to another location. In the WebGL demo it might be visible, and in extreme situations it becomes a weird chain-reaction, in which one agent goes around into a new position, pushing another agent to do the same. 

I'm going to give up on this idea for now, as the desired effect is really implemented already by Unity NavMesh. I'll try to integrate that system as my next step.

Files

Johnny's Goldfish Simulator (web).zip Play in browser
May 09, 2021

Get Johnny's Goldfish Simulator

Leave a comment

Log in with itch.io to leave a comment.