Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AI and Deep Learning by (50.2k points)

I'm working on an overhead shooter and what happens is, over time, as I move in circles around the arena, the enemies will begin to stack on top of each other until they're one giant stack of units. It ends up looking pretty silly.

The AI is pretty simple and basic: Find the player, move towards him, and attack him if he's in range.

What's the best way to push them away from each other so that they don't all end up on the same spot? I think flocking is a bit overkill (and probably too intensive since I'll have 100-200 enemies on the screen at a time).

Ideas?

Thanks!

1 Answer

0 votes
by (108k points)

The enemies periodically recalculate their direction, which is usually towards the player (if they are visible), or towards an AI node (if the player is not visible). At this point, we simply added a random amount of the velocity perpendicular to their direction which now causes the enemies to move towards the player but avoids the annoying clumping. 

You could establish a potential field for each unit that associates a "height" to each location on the map. Each unit goes in a way that tries to minimize its potential, perhaps by taking a step in the direction that moves it to the lowest potential that it can in one step. You could describe the potential function so that it slopes toward the player, causing all units to try to move to the player, but also be very high around existing units which then avoid bumping into one another. 

If you wish to learn about Machine learningArtificial IntelligenceNeural Network, and Natural Language Processing then visit this Artificial Intelligence Master Training Course.

Browse Categories

...