Hey,
So almost 8 years ago I started creating my very first RTS Game on Unity. It was really a blast and I managed to recreate very close experience of Warcraft 3 on Mobile
.
For agent avoidance I used Unity built-in navmesh agents. However I quickly noticed that it does not perform that well in most critical RTS cases (etc. circling targets, getting around standing agents). I decided maybe I should try to roll out my solution, it should not be that hard, is it? Boy… I was wrong… Not long I realized outside RVO solution, many successful companies tend to not share their navigation tech (Maybe things did change now). I remember spending many hours dissecting one of the GDC videos where blizzard employee was show-offing their local avoidance, but leaving all details unexplained
. Finally, I came up with cool solution…
Fast forward to now, sadly project did not reached the daylight for various reasons. Yet I noticed there is a lot of value in my custom local avoidance solution. So I decided to create a package out of it using even more powerful algorithm with DOTS.
For version 2.0.0
I released complete minimum API so it could be fit into any design with ease, regardless it is OOD or DOD. Here is small example with one obstacle and drawing it in gizmos:
void OnDrawGizmos()
{
using (var sonar = new SonarAvoidance(transform.position, quaternion.identity, InnerRadius, OuterRadius, math.length(Velocity), Allocator.Temp))
{
sonar.InsertObstacle(new float3(-1, 0, 0), math.radians(180));
if (Obstacle)
{
sonar.InsertObstacle(Obstacle.transform.position, ObstacleVelocity, ObstacleRadius);
sonar.DrawObstacle(Obstacle.transform.position, ObstacleVelocity, ObstacleRadius);
}
sonar.DrawSonar();
sonar.DrawClosestDirection();
}
}
This solution end up exhibiting many cool behaviors like:
- Manages navigation out of concave obstacles
- Circles target
- Avoids head to head moving
- Accurately respects radius
- Predicts collisions and avoids based on that
- Avoids only when necessary
Some of them can be seen in:
To honor the Starcraft2 I even recreated Zerg demo:
In Bigger crowd:
Finally, decided to bring back new solution to my Old game and see how it works
:
Package AssetStore
Support Discord
Demo Zerg
Now for version 3.0.0
I plan to create some MonoBehaviour implementation so there would be possibility to use package without coding. I am currently fixated on idea having MonoBehaviour as wrapper and behind the hood running ECS in hybrid mode. This would allow code to work with other MonoBehaviour components and also having all advantages of ECS. Also as bonus this enables easy way using ECS only for those who would want. I am curious to hear other opinion about this approach, as this would require having ECS in your project.
To give better idea here is the scene with 10 agents. Each agent GameObject has its copy of Entity as seen in Entity Debugger. Their settings gets in sync.
Here is image with Entity selected.
That is kind a it, thanks for taking interest.













