Where should i need to use entities and DOTS features?

Hello everyone,

I am currently working on a 2D semi-open world automation game and have some questions about DOTS. I understand that I need to use entities for certain elements like world tiles, enemies, and buildings, but I’m unsure about using them for everything, such as the player. Since there is only one player in the game, I wonder if it’s necessary to use entities in that case, or for some managers that perform minor tasks or calculations. I believe I don’t necessarily need to use entities in those situations.

Secondly, I would like to know how I can animate elements like tiles and building machines. I have looked for solutions, but many options are quite expensive in my currency, and I cannot afford them. The hybrid solution suggested by some YouTubers and developers doesn’t seem suitable for me, as having a game object for each building that needs animation would result in performance issues.

I appreciate any help you can provide.

Thank you!

First of all, while DOTS is a good options for such kind of game, it’s not the only option.
Factorio for example, while it was made with C++, it was made without ECS, and in fact it was made with OOP in mind.
You can throw multiple threads at solving a problem, but the key is efficient algorithms.
If you want to be sure that performance wouldn’t be a bottleneck, then of course try DOTS.

I’m not expert in DOTS, but I have years of experience in ECS, and my advice, if majority of your gameplay code is built upon ECS, you should probably use it for the rest of your features.
Exceptions are probably UI, Audio, VFXes or non-gameplay related things (but it all depends).

With player you should just care less about performance. Like there is no reason to write jobs or utilize cache friendly layout for single thing. But if you already work in context of systems and components, I see no reason to use another workflow for specific features, because you will be required to connect these two worlds, and will probably lose some ECS benefits.

Regarding rendering, I’m not sure how many things will be visible on your screen at once and what style will your game have. Will it be something like Factorio with sprite animation? Or will it be Spine2D?
The general advice is, utilize batching as much as possible, I’m not sure about instancing for 2D, but you can research that too, maybe try reusing same sprite/animation state for the same objects (e.g. conveyor belts), and just don’t render things player won’t see.

Also, try benchmarking. Just make simple scene with dozens of objects which constantly update their animation and check what performance is and how can you optimize it.
Maybe you will be required to write your own thing if nothings suits you. If you know limitations of your game, like it will be 2d or 2d tile-based, you can google/write specific culling/streaming/chunk/partitioning algorithms which will suit your needs. Unity GameObjects are probably not suitable for your genre out of the box.

Alright, I understand. I’ll go ahead and use DOTS for those features too, even if it might take more time.

I was using sprites and sprite animations, but I realized that even without animations, rendering still took too much time. I haven’t really tried batching and optimization yet. Instead, I experimented with using Mesh Renderer, and I found that it performed better. With Sprite Renderer, I was getting around 35-40 FPS, but with Mesh Renderer, I’m seeing around 200-220 FPS. So, I think I’ll switch to using Mesh Renderer for tiles and objects without animations.

Thanks for the recommendation! I’ll definitely try benchmarking and testing different approaches.

And thanks again for your help. I feel like I have a clearer direction now.