Greetings !
You may have guessed what my problem is from the title, but first of all let me give you some context so you understand my needs better.
I am a student in IT who’s about to start a one year long student project with 4 friends of mine who are also students. We are going to make a game, and it’s a pretty ambitious project to be honest : multiplayer might be where we go too far given our skill and timeframe. But no matter.
The game is about players fighting in 1v1 matches that can last between 10 and 20 minutes. Players will be able to summon soldiers to help them control key areas and will also control a “main” character directly, so it’s not an RTS (meaning there are no “squads” or “group” mechanics, each soldier is a singular entity, at least gameplay wise). Neutral soldiers will also be spawned as a “game ender”.
This means there will surely be MANY soldiers, probably in the hundreds, on screen towards the end of the game, and given it is a multiplayer game based on reflexes a lot… we cannot afford to have any performance problems or lag.
After making a simple prototype that simulates 1200 soldiers in real time, I ran two tests :
-
One in which the soldiers were Idling (their AI was not turned on), so obviously this was mainly to test how Unity and my computer (I have to take that into account, my computer is very good and I think quite a bit higher than average, at least in RAM and GPU, GPU is an intel core i7 with 4Gz frequency). The game was smooth at 70 FPS, but I expect rendering to be much more expensive later, as there will be more complex animations, particle effects, lots of spawning and despawning…
-
One in which the soldiers had their AI turned on, and fought a 600 vs 600 battle. Now my targeting system was being a very big pain in the buttox : I use a coroutine so I believe it does limit the impact it has on FPS but still, the game was running at about 30 FPS when all the soldiers were alive, and then gradually went up as both sides started getting losses.
The AI of a soldier is a simple FSM where they either “Stand by”, just going to a random point and then generating another random point upon reaching the current one, or “Fight”, going towards their target until in attack range, and then proceed to attack the target if this soldier is not currently being struck at.
Each AI is always searching through the entire array of soldiers on the map, so that must be most of the processing power is going (at least the profiler says so), also each soldier is constantly raycasting forward to make sure they do not go through another soldier. The terrain is flat so I didn’t give them any physics, just force them to always stay at a certain level. If raycasting isn’t too costly I might use one to make them ‘stick’ to the terrain bellow them.
So, here’s my problem. Long story short, I’m trying to figure out how to render and manage many individual soldiers, so that your average gamer PC could handle at least a thousand soldiers in real time each having at the very least a few hundred faces.
For the rendering part, I’ve explored and searched a bit and stumbled upon videos like this one :
and also a thread he made about how he achieves that.
The thing is, he’s not very precise as to how it all works, but I’ve picked a few things up.
So now I’m trying to learn how to use Graphics.Drawmesh instead of using Gameobjects for each soldier, but I’m still trying to figure out how I can use it to render animated objects without having to store tens of models representing frames of each animation. Also that means I won’t be able to use mecanim, which is going to make things even more difficult.
But the problem I’m foreseeing with this is, how on earth am I going to allow players to target soldiers with spells if I can’t use raycasts ? Since there won’t be any soldier gameobjects, there also won’t be any colliders associated.
All in all, I’m pretty confused and probably trying to solve an above-my-league problem as I often do. Nevertheless, I’d greatly appreciate if one of you could give me a hand.
Oh, and feel free to tell me that this is beyond what a bunch of students can do in a year. I think I already know but it’ll be clearer if someone with experience tells me ![]()
Thanks for reading that wall-o-text. Cheers !