Hello everyone. Firstly I'd like to explain my setup. Here is the image of the battlefield https://imgur.com/a/AW8UVWr
The setup is as follows:
- Custom Engine. 5 steps a second (server ticks)
- Units are 32x32 (for the time being)
- Map size is 800x512 divided into 4x4 tiles. I am doing this as it's the best solution for pathfinding, general computation of collision, location, etc. (Movement speeds are measured in how many 4x4 tiles they traverse in a step).
- Units are purely AI controlled no interference from the user
The general movement flow would look like this :
1) AI finds the closest/ the best unit to go towards.
2) Movement handler finds a free spot near that target and marks it as goal (so other units dont path towards that point), then generates a path with A*, marks a couple of steps ahead that the unit will traverse that path so that other units dont path and interfere.
3) Movement system moves the unit ahead x tiles.
This in theory looks okay, but it has a lot of flaws:
1) It doesn't work at the moment, as placing two units next to each other breaks them both because of the mark system presumably (marking the path makes both unable to traverse it)
2) A* is used even tho I have no obstacles besides other units. I'd like to switch to Jump Point search probably.
3) I have to recalculate the path every single time the destination (goal) changes. And that often happens, for example, we have two units. Unit A targets unit B and in reverse, every time they move towards each other, the goal has to change and the path has to be recalculated even tho the path is going towards the target properly.
4) Units should probably move together and be aware of each other's paths somehow.
Basically server ticks 5 times a second, AI generates actions for AI to perform, Handlers handle the actions, Systems do the other work necessary. But I cannot think of a good flow for the movement to work properly. Now they are either getting stuck in each other or not moving at all. I don't need a smart AI, just good enough to go to the enemy, avoid others, take a free place next to that enemy and go on from there.
Units always start at the opposite sides of the battlefield.
I'd appreciate any thoughts/ theory/ articles/ tutorials/ books. I've been reworking the movement system for the third time now and it's been really tiresome. Any help is appreciated, please feel free to ask for any additional details if necessary!