Unity and ECS Integration

Hello all, it’s been a while since my previous blog post, which was mostly showcasing off my editor version of a bullet pattern system.

In those few months, I’ve updated my system to use a global bullet manager such that now all lifeTime logic and movement is not handled individually by every bullet.  And man, was this a large performance update for me.  Previously, I couldn’t get 4-5,000 bullets to move adequate without incurring some fps loss.  Now, I can get by with about a few frames loss at the initial spawning.  I’ve also improved the look of the editor and added text info. support for the various input fields.

I am now very satisfied with this implementation of my Bullet System Editor, which is OOP and MonoBehaviour centered.

In a way, this leads me to my next update and adventure/implementation: Unity’s Entity Component System, which comes as a preview package in Unity since Unity 2018.1

I first heard of ECS during the GDC 2018 back in March 2018.  I didn’t quite understand it then, but now in the summer, when I have more time now to pursue my passions, I was able to study and find out more about this concept.  For half of July 2018, I slogged through the 2D ECS samples to understand the logic behind the systems.

Unity’s GitHub Resources on ECS

Link to Unity ECS 1

Link to Unity ECS in Detail

Link to Unity ECS Game Samples

I recommend just giving a quick browse through these links to understand what ECS entails.

In a nutshell (or at least for me), ECS is a Data-Oriented-Design (DOD) principle of programming.  Entities (E) are just general objects (usually IDs) with associated Components (C) that contain data to be operated on in Systems (S).  ECS design is meant to break down a game into many components and systems and allow for scalability, flexibility, and runtime performance.  Because of how entities are laid out in computer memory (side by side for instance), one operation can operate on a single “array” of entities without having to go through several pointers to memory.

This was absolutely perfect for what I wanted to accomplish: massive amount of bullets with solid run time performance.  And I have to say, after two weeks of frustration, it’s finally coming along.

Screenshot (199)

Screenshot (169)

I am quite excited for Unity’s ECS and its future release to full production.  As of right now, there are a few inconveniences, such as no competent editor preview of the entities (I have to use the Entity Debugger, and as you can see, the components are greyed out, making it hard to see the values), and there is no physics integration yet.

But the future looks very bright for Unity.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s