Test 3

Somewhat short blog post with video.  I’m running into a development/scalability issue where I’m generating pretty much variations of the same pattern.  It’s…frustrating, to say the least, when my visual editor has to be updated to include all these variations.

 

Anyways, here is a 2D demonstration of my 3D system.  Extremely pleasing flowery patterns

 

Unity ECS BH System Test 2

Hi, it’s Kevin Wu

Just posting another progress video for the BH system.

Since the last video, there are a few more changes (although not demonstrated in this particular video):

  • -Improved Editor UI/functionality (now, it uses a Reorderable List for a user friendly interface)
  • -More patterns (Cylinder shaped, Cube/Rectangle, Star Shaped, Icosphere, Random Emitter)
  • -Experimental Procedural Patterns (As in, instead of emitting one full pattern in a single frame, the entity emits the pattern over a certain amount of seconds)

I’m still working on the experimental procedural patterns.  An example of what I mean by this can by seen here:

(timestamp at 1:30 if the video plays at the beginning).

At the time of this particular prototype (Dec. 2017), I was generating star shaped patterns through Unity’s Coroutines.  This let me “wait” between each spawn of a bullet, and it looked pretty good.

In Unity’s ECS API (or at least in the Job System), there is no concept of “waiting” in a job.  You send data to a job, and it executes and processes the data in conjunction with other jobs.  I can’t stop it nor stagger its execution.

To get around this, I appended two private variables to each BP entity to keep track of the spawning intervals and made a new function for each Bullet Pattern to spawn X amount of bullets only based on that current interval.

I guess that sounds kind of confusing, but basically, I stagger the spawning of bullets outside the jobs, and in a job, I spawn only 1 or two bullets.  This does mean that it takes many jobs to complete even one pattern over time.  In return, though,  I get massive performance increase because I’m not spawning like 4000 bullets in a single frame.

 

Unity ECS Bullet System Video Test 1

After another few weeks (and new changes to the ECS preview API), I finally got to a good point where I could upload a preview video of this converted BH system

 

It demonstrates test patterns, bullet movements, and target effect.

My next plan is to improve the spawning of the bullets.  ECS is great for managing entities that have already been instantiated and not so much when you spawn a couple of thousand new entities in a single frame.

In my OOP version, I had used object pooling to reduce the performance cost of “creating” bullets.  This means that all I had to do was “cheat” and not really instantiate bullets, but use previous and premade bullets and change their speeds and directions.  But in ECS, there is no concept of object pooling, so I had been creating entities literally at each execution and setting their values there.  As you can see, I suffer 5-7 frames everytime I spawn around 1600 entities, and this gets worse as I tried spawning 5000 in one frame.

One of the things I am hoping for later in the future from Unity is the ability to Burst Compile the Entity Manager.  As of right now, the burst compiler doesn’t work with it, and my system heavily employs the Entity Manager in its bullet patterns creations.

 

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.

The Bullet System Editor V1

Hello all, it’s Kevin Wu.  I haven’t posted a blog update in…months.  Mostly because I’ve been busy.  Also because I didn’t really have much to post.  But  here’s a video.

This time, I’m moving way from the (bad) hard coded bullet pattern as seen in December 2017 to a more modular way of doing things.

 

 

This version, Version 2.0, or V1 for the “official” title, gets rid of the hard code and attempts at making a modular bullet hell pattern system for use in 3D. Well, mainly 3D; certain patterns like circles are usable in 2D levels, too.

As you can see, bullets are generated based on a pattern and an additional parameter called enchantment. An enchantment is merely the bullet’s second movement after it is emitted. Bullets use rigidbody physics to move.

Made with Unity 2017.3

With the introduction of Unity 2018 and the job system and ECS, I will make the switch to those, and this system will will probably increase in performance.