Finding a good solution to unit movement in my game

Started by
2 comments, last by sir7 3 years, 1 month ago

Hello everyone,

I need some advice/ opinions on what combination of pathfinding solutions could I use to approach my problem. I have this setup currently https://imgur.com/a/bJvXDjb . Two armies approach eachother from different parts of the screen, units are about 32x32 but may vary in size. Each unit should approach its closest enemy and take up a free spot and duke it out. Currently the problem comes when multiple units meet up or multiple units on a single unit, they either get stuck, they don't know how to go around eachother, or take a better position. I am using steering + flowfields (but flowfields are useless for my usecase as I don't have a single goal). All units are AI controlled. I've went through 4 iterations of the movement, from pure steering to grid-based movement, to A* to this that I have now. And all of them had the same problem (some of them had more than one) of meeting with the opposing unit and taking a proper place to attack.

Any advice on what I could do to approach this problem would be really appreciated, I am sick of trying something new to see that it fails halfway of what I want it to do. I've seen that SC2 uses boids/ steering for this but I haven't found how they get the units to surround and stuff in more detail. My armies wouldn't be as large, no choke points, everyone is always moving, everything is AI generated so there is no interaction with the player, etc… All of these points do make it a bit simpler but I still need it to be somewhat performant as its happening on the server.

Any additional information I'll be glad to provide. I am writing my own engine tho so any articles/ resources on the details of implementation are greatly apprecited!

Some more videos

Advertisement

Your description seems to mix up three different issues, so let's break them down:
1. Find best enemy to approach. Or, potentially a better thing, find a general area with enemies to approach, don't select just “one” to attack as of yet. So, path find to an ‘area’ or in a direction until you get close enough to consider attacking.
2. Select the best enemy to attack. Basically when within a certain range of any specific unit, decide if that will be the one to attack. Maneuver into range and attack.
3. If other entities are near, maneuver around them to a point where I can attack. This can often include several behaviors such as slide “around” friendly units, attack enemy in the way instead, etc.

Given these three items, there are several methods to approach it but I'd likely suggest starting with probably the most common, influence maps. Influence maps are basically just a grid which you fill with values based on the units/obstacles etc in the world. A pretty good overview can be found here: https://www.gamedev.net/articles/programming/artificial-intelligence/the-core-mechanics-of-influence-mapping-r2799/​ with a more specific video description here: https://youtu.be/6RGquWxNock​ . Between those two items, that is probably a better overview of my suggestion than what I can write up here, so take a look. I think that Dave's video (second link) is likely to be of more interest to you, the first article is more of an overview.

@All8Up Thank you, I'll give this some more research and see what I do!

This topic is closed to new replies.

Advertisement