Train Defense 2‎ > ‎

Carriages and Particles

posted Aug 2, 2012, 9:04 AM by James Podesta
I've nothing good to say about unity's particle systems.

Wasted many nights trying to wrangle Unity's particle system.  It has a new Shuriken particle system which is broken when it comes to spawning a single particle at an arbitrary location, velocity and colour, and an old particle system that can't seem to fade out alpha without changing the colour.

So I've got some placeholder particles working but its in a pretty bad state.  I could write my own particle system but they have no support for point sprites and trying to do an optimised particle system using the dynamic mesh interface is going to be fairly inefficient.  I'll just have to leave it for now and try again later.

On a different note, I've added carriages. At first I thought they'd be too special purpose to use my existing turret attachment system so I tried implementing a separate system for them... but failed miserable in a pile of code poo. So I regrouped and decided to see just how well the attachment system could handle carriages.  Turns out, with some simplifications, the attachment system handles them fine.  There was a few script dependency issues but these eventually worked themselves out.  The train engine is now the only script that gets an Update() called by Unity. It calls a RepositionAndUpdate method on the attachlist script which calls the same method on all its attachable objects. The attachments themselves call their attachments and so forth. 

The attachList script also has a spawn function which can, very carefully, spawn an initialise a gameObject.  There's some tricks to that also in Unity as instantiating a gameObject gets its Awake() called but not its Start(), so you need to avoid using Start() for items you will spawn.  I may end up using object pools for speed and avoiding garbage collection, but they are quite wasteful of memory when you have a large variety of prefabs. I don't seem to need them for now, but the option is there for later if I hit any performance issues.

Prototype 008



Comments