3
\$\begingroup\$

I want to implement a demo like creeps laning in Dota 2. So for simplicity, there is Left team and Right team, they are enemies.

  1. Units from Left team move toward Right base, and units from Right team move toward Left base.
  2. In their path, if those units encounter unit from enemy team, they will start to fight the enemy unit.
  3. One unit could attack an enemy unit.
  4. In their path, those units should avoid ally unit, they should not collide each other.

For 2 and 4, I want to have the feature that is: When encounters any enemy, one unit should seek its path to be able to fight the enemy unit. Consider this image: enter image description here

There are some units blocked by their ally, so when an unit blocking the path disappear, another closest ally unit should move on, or move to attack their nearest enemy unit.

I wonder if A* should be applied for the demo. My demo is more simple than Dota 2, it does not have static obstacles, it just has dynamic obstacles (moving units). My main question is, What strategies/algorithms should I apply to implement my demo?

Thanks

\$\endgroup\$
  • 2
    \$\begingroup\$ If you have no static obstacles, then you might want to look into avoidance behaviours rather than pathfinding per se. \$\endgroup\$ – DMGregory Apr 18 at 11:37
  • \$\begingroup\$ There are lots of solutions. Some keywords to look into: Swarm pathfinding, collision avoidance, potential fields, boids \$\endgroup\$ – BlueRaja - Danny Pflughoeft Apr 18 at 19:20
  • \$\begingroup\$ Thanks @BlueRaja-DannyPflughoeft and DMGregory. I'll try Reciprocal n-body Collision Avoidance, hope it is not overkill. \$\endgroup\$ – KeNVin Favo Apr 19 at 1:45
  • \$\begingroup\$ Oh, another common term is "flocking algorithms" \$\endgroup\$ – BlueRaja - Danny Pflughoeft Apr 20 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.