After coming across a thread on Reddit I was inspired to try and make a game with 1000 units in Unity to get a feel for what it takes to make an somewhat optimized game in Unity. Usually optimization is something I’ve never had to care about when making games so this will hopefully be a fun challenge.
My first approach made this seem impossible because I tried what I thought was the simplest, most optimized thing I could do and that was just to have 1000 game objects which I moved in Update(), but apparently having 1000 Update() loops is the opposite of optimized. I later learned that the built-in navigation system is very optimized and not only does it handle movement much better than my naive approach, but suddenly I had actual pathfinding and object avoidance as well, things I thought would be extremely hard to implement.
I then wanted the units to fire missiles at each other, but 1000 rigidbody missiles at once caused a lot of issues. I thought I could optimize this by using particles instead, but apparently when you want particles to be able to collide with 1000 objects they are much less performant than the built-in physics. I also tried a raytrace approach I’ve used in a lot of my games, but that was also less performant than the built-in physics so I reverted to just using rigidbodies, I just limited the number of missiles for the time being.
I then added some particle effects, trails, sounds, a terrain and a simple camera controller and suddenly things started to look really cool. The look I’m going for is inspired by Homeworld: Deserts of Kharak because I think that game looks really cool even though it doesn’t have that much else going for it. And I just love simulating projectiles. I then implemented some object pooling which I’ve never used in Unity before and so far things are looking pretty good.
The most important thing for me with this project, as with any of my projects, is that every single thing should be simulated and consistent, I don’t want any smoke and mirrors or tricks. I know this is kind of the opposite approach of almost everyone who develops games, but I’ve never had to actually release a game so I can do whatever I want.
I know released games with thousands of units use all kinds of tricks to only simulate small subsets of units at a time etc. etc. and I don’t want any of that, I want each unit in my game to behave as if it was the only unit in my game, but we’ll see how realistic that actually is. I’ve already had to limit the number of simultaneous missiles by a lot, but that was also partly because 1000 missiles didn’t look or sound very good. ![]()
At the moment I’m not sure where or how far I’ll take this project. Currently it’s just an observable demo, I’m not sure if I want to make it into a game you can actually control or not. I know I want to improve the graphics quite a bit and I’ll focus on trying to squeeze out additional performance while at the same time adding more features, I guess.
You can download the project or standalone versions for Windows or Mac from the above link. I reserve the right to stop updating the downloadable project at any point if I realize I want to turn this into a game or if I want to use commercial assets or for whatever other reason, but at the moment I’ll update it whenever I update the standalone builds.
