Log 05
My goal was to finish the first scene by the end of July. Tragicomically, I doubt that will happen.
Since the last update, I mostly worked on the firefight scene, where MACHINE and the arm fight off a few WEAPONS after a short break. I’ve got a nice setup now where the WEAPONS, as shadowed meshes, fly back and forth (with some randomness, so it looks like a lot of them zipping around rather than 5 of the same object going back and forth), and there are ceiling spotlights that can also shoot lasers to emulate the battle. I also updated MACHINE’s animations; she now reloads and keeps firing, and that’s enough to get her through the whole firefight.
It still looks a bit awkward, but it’s in pretty good shape. The only thing left in the scene left to animate is the last bit after the firefight, where MACHINE stops to survey the damage and the arm flies off again. Under the hood, there was a lot more programming this time around, however. Namely, around effects pooling – with all these lasers and explosions and gunfire everywhere, Unity would by default have to create and destroy a lot of objects pretty quickly. This is not a problem in something as small as a stage play, but in a game with more enemies or weapons, it could be a nightmare, performance wise; object creation is computationally expensive.
So, instead of doing that, I implemented an object pooler. The concept of pooling is that, at game initialization, create x instances of an object (say, an explosion), but keep them hidden and deactivated. When something explodes, instead of creating a new explosion object, you instead take one of the hidden explosion objects that was already created, activate it, and have the thing explode. After the explosion animation is done, rather than destroy the object, you reset it back to its initial state, and deactivate it – and thus, it can be used again and again. The object pooler manages the ‘pool’ of objects, providing the deactivated object for any other system to use. If, say, we needed to explode a bunch of stuff at the same time and there weren’t already enough created objects, the pooler creates new ones as well.
Is this premature optimization? Oh, definitely. But it’ll be useful for future projects, and so here I am…
Finally, I went and did some more logistical things. I documented some of the learnings I made about cameras and systems (though I do need to write a wiki page for the object pooler), and I created a camera screen shake effect which is used exactly once. There are more effects I want to make; in addition to screenshake, I’d want the lights to flicker at the beginning, and I still need to animate the main spotlight. But at this point, I think those effects are secondary to blocking out the rest of the scene.
Also, the timeline is looking fairly gnarly now: