Hello everyone!
Last semester I worked on two games as school projects. It was actually my first real experience with Unity, and with one of the games, I jumped straight to DOTS. It might have been a mistake, but I think I learned a lot. I created a small 2D space combat sandbox (more like a simulation than an actual game) with some boid simulation and so on. I want to continue with the project, but I feel like I should take a step back, rethink the current state and improve it. That’s where I could use some of your feedback on what I did right, what I did wrong, or what I seem not to understand properly.
If you’d like to look at the code (I would really appreciate it), you can find the project here GitHub - EnviloN/SpaceRTS-ECS: A small 2D Space RTS made with Unity ECS (DOTS) with Boid (flocking) system.. I tried to comment and document everything, so it should be fairly easy to understand. Also, the comments reflect my understanding of the ECS, so there might also be something to give feedback on.
About the project
I think the project is well described in the README.md of the aforementioned repository. Here I would like to point you to more specific parts of the project (if you don’t feel like digging through the code) I think might be problematic. I will also list some systems implemented in the game so that you get an overview.
Implemented Systems
-
Input System
-
Camera Movement
-
Starship Spawning
-
Unit Selection
-
Unit Highlighting
-
Starship Movement System
-
Flocking System (boids, steering)
-
Targeting and Combat Systems
-
Quadrant System (spatial partitioning for flocking and hit detection)
Potential problems
Input system
I have one central input system that is (I believe) listening to all input callbacks and handling the user inputs accordingly. What now feels a bit inappropriate to me is that I do all the handling in the OnUpdate method, where I basically do several Entities.ForEach calls for each component specifically created for this input data and set the input values to it. These components are usually on only one of the entities (e.g., camera or cursor). I feel like some message passing would be a better solution?
Camera
Basically, when I was working on the camera movement system, I didn’t find a way how to work with the camera in the ECS. I created one entity called CameraRig that I work with in the ECS (I move it with a camera movement system), and another MonoBehavior script on the camera takes the value from the CameraRig’s Translation component and sets the camera’s transform.position accordingly. I also use perspective projection on the camera to perform the zoom by moving the camera along the Z ax. Is there now a better way to go about this?
Unit Highlighting
This was a big pain. I have no idea how to do this, and I have no idea what I have done to get it working. I was trying to do several different things—one of them being creating a custom renderer. In the end, I was able to get this done by creating a ShaderGraph that is using a color property exposed in a component, which I can change in the systems (if I understand correctly). I had no idea what I was doing, and I was desperate. I feel this solution is by no means scalable and extensible.
To be completely clear, I did not aim to do the highlighting by changing the units’ color. I wanted to display a circle or a glow around the selected starships. I also wanted to create a selection rectangle displayed when you are trying to select some units. I had no luck there.
Shared Components
There is a BoidComponent attached to every starship entity, that contains the configuration of the boid behavior. Logically, this should be a shared component, but I was unable to use the AddSharedCompponent in the ShipSpawnerSystem because apparently, I cannot use it with CommandBuffer and or Burst? No idea how to go about this.
Thank you for reading through this and for any potential insights and feedback! ![]()

