By: Allie Keats | 26 January 2018
This week saw some new progression in re[Mod], but it also saw me come down with the flu, so my contributions this past week haven’t been quite as large as I would have hoped.
There were some important improvements made, the first of which being that the sniper scope “aim-down-sights” effect was rewritten to use a screen overlay instead of the mediocre “move the gun to the center of the screen” that we were doing before. Initially, my plan was to essentially use a switch inside the WeaponPartScope script which would cover the different effect types, but I quickly found that that was not flexible enough, as different effect types would require different types of data and exposed variables.
The solution was to use a ScriptableObject type, and a plug-and-play type system where each scope had a reference to a different “type” of effect that it would call into when aim-down-sights was activated and deactivated. The benefits of this included:
I was also able to take advantage of new Post-Processing stack’s flexibility. The newest (beta) version of Unity’s stack allows for the creation and modification of effects at runtime, which I took advantage of by using a rounded Vignette effect for the screen overlay of the scope. I also wrote a new, simple effect called Quickfade which, provided a color and a time, fades the screen to that color through a shader and then back again when the appropriate call is made. This feels significantly cleaner than using a full-screen UI.Image would be and, though I haven’t profiled it, my hunch is that it’s more efficient as well even with the overhead of the Post-Processing stack.
The other major item that I spent time on this week was refactoring the hitscan bullets in re[Mod]. Previously, they were a real drain on our network resources, due to some “get it working as quickly as possible” decisions. Previously, this was the flow for a bullet:
This has now been significantly refactored into the following:
This is a massive improvement in network traffic which I am happy with. The only improvement from here is to change the Instantiate and Destroy calls into calls into the pre-existing GameObjectPool class that I have, which is something we’ll spend some time on a little further down the line. Still, when a project starts to get to this size, every little bit counts!