I’ve just finished working on basic mechanics of my game (RTS), and i’ve learnt about ECS. Should I use Unity ECS or try something like LeoECS?
Seems to me that LeoECS is a pretty old project while Unity is pushing hard to integrate ECS for all the engine, I’ll say wait until 6.7 is out than think about it, a lot has changed from 6.3
That depends on what is drawing you to ECS in the first place.
Since this is an RTS, you probably don’t care about NetCode, physics, or the character and vehicle controllers (though feel free to correct me if I’m wrong). So the main advantages of Unity’s ECS are Burst and Jobs friendliness (though some other ECS solutions also do this), a built-in rendering solution, and scene and prefab serialization with editor workflows.
Other solutions typically benefit from better expressivity and slightly milder learning curves. I won’t mention any one in particular.
Best of luck on your RTS!
Actually, these things are very important for me. Physics are the only way to implement realistic artillery system (or, maybe, I don’t know about something).
Controller is important too. I’m planning on making player control commander on a battlefield due to current plot implications. However, it’s optional
I had planned basing unit movement on physics too until I realized how performance heavy it would be
There will be two kinds of missions. First ones contain very small amount of units (5 - 15), and second ones feature classic RTS experiance. I’m wondering if different choices can be applied to different missions
No.
Quite simply “No.” because you haven’t given any reason why it might be reasonable to do so. Do you want to have thousands of RTS units? In that case it’s a possibly maybe. Do you HAVE to have thousands of units or else your game won’t work? Then it’s a yes.
If you plan for 100 units per team with 4-8 teams you should be fine without ECS provided you profile and fix any obvious issues.
For an RTS the go-to optimization from the start is to process all units from a central place. Do not give each unit its own scripts which have each unit perform all of its logic on its own. That’s wasteful. When you’ve exhausted all the usual optimizations, then look into the Jobs system. Jobs can significantly speed up masses of units without having to use entities.
How many artillery units would there be at most? What is their fire rate? Unless you have hundreds, if not thousands of shells flying about, the firing animations and impact vfx will be more costly. An arc trajectory, even factoring in air resistance and wind, is trivial to calculate and simulate compared to the complexity of Entities. And all of these flying shells could be simulated within a single parallel job, started in Update and completed in LateUpdate.
Hundreds of wheel colliders, possibly. But this is an RTS, you’ll see those (presumably) tanks and jeeps only from the top. So a simple sphere-based arcade racing thing should be sufficient.
You aren’t trying to do something like this, are you? The Last General on Steam
That game uses Unity’s ECS, but most of that is for the environment. Although with how much is going on per frame, ECS for the simulation also helps.
So I should try to optimize everything using using regular tricks and, if I find them insufficient, I will use job system.
Is this what you’re telling?
Thanks a lot for this advise
Surprisingly it’s very similar to what I’m doing now
However, there won’t be ability to posses different units. Player only controls one unit which can use vehicles or mechs
I won’t suggest ECS in general for this particular project, because it takes time to wire your brain away from OOP. It’ll be painful if you spend a great amount of time to learn but just can’t get the gist of it.
So you should only learn ECS separately from that project in case you want to get to know it in a more comfortable way, without any pressure. You can even use a watered-down version of project as a playground just to have a real life comparison but do not take it seriously as an ultimate goal or something.
No one can tell how long it will take you to learn ECS.
Unity ECS will help you a lot if you are making an RTS. I would recommend it for sure. I am working on an RTS using it. But it depends a lot on whether you are networking it and many other things. You will need a lot of things, but ECS will be a good base to build on.
Why are you even considering LeoECS? That seems really random.
I don’t mind spening a lot of time if it’s necessary
I heard that it’s easier to learn than Unity ECS and also isn’t strictly tied to the use of multithread system
Unity ECS is not tied to the use of multithread, use multithread only if you need it, it is only much simpler if you want to use multithread.
Unity ECS was built upon a multithreading foundation aka Job system, but you can go single thread exclusively, there is no hard restriction that prevents you from doing that.
If it’s so, are there any significant cons (except learning curve) I should consider?
Are any ECS worth the effort if there won’t be more than a few hundred units on a scene?
My opinion is ECS allows better maintainable code. But if it’s not your target then it’s also the greatest limitation. Because to achieve maintainability you have to obey multiple strict rules, they usually results in more verbose code for small scope projects. Thought process might be affected as well, you’re likely to take more fine-grained approach that might be slower.
Another things is, ECS is all about more specialization and less generalization, there is less existing code you can bring from one project to the other verbatim unles the functionality is exactly the same between 2 projects. On the other hand, if there is something you can build into a standalone module, then the reusability of ECS is greater than that of OOP. Because ECS is a true composition workflow. Lego is a great example for this.
You should take into account all the live functionalities that are happening within a single frame rather than just the existence of your soldiers.
So if there’s only one script which operates every unit instead of behaviour script on every unit it will be less performance heavy? (isn’t it one of key features of ECS?)
I think it hasn’t been a problem for me yet. Anyway, thanks for the advise
Theoretically, yes. In reality, you should profile to prove an assumption if you’re on normal OOP code path because OOP data is all over the place. In contrast, most ECS solutions don’t have to prove anything, performance is intrinsic because their data is tightly packed in memory and is friendly to CPU caches.
So ECS is more manageable?
I suggest you should be more specific about what’s in your mind. I don’t understand this “manageable”.