Things are coming nicely, and it's finally starting to look like a game, instead of just a bunch of pieces.
Since my last update, I've done quite a bit, including some major refactoring, UI Design, setting up a pixel perfect camera, modifying graphics and experimenting with exploding enemies and blood effects.
First off: when I'm coding, I'm very much in a trance, and I have a bad habit of thinking that I'll, "Just make it work first, then make the code pretty later". All too often, I'll get carried away and don't take the time to do the second part. As a result, I actually had lines in my code like stats.UpdateUI(). I think that one method call speaks volumes.
I set up probably half a dozen new classes (including UI, Audio and Shop Managers), and the project is, once again, pretty maintainable.
While I was refactoring, I was curious how other programmers work. Do you guys actually spend a lot of time on design before actually beginning implementation? This was pounded into my head in college, and I definitely see value in it, but I often find myself thinking that it's just too hard to plan for everything up front.
It seems to me that, for a smaller game like this, just having a small design doc roughly outlining things and kind of winging it during development is okay. But for a bigger project, much more time should be spent considering code structure, etc. What are your thoughts on this?
After I refactored, I played the game for a bit, microanalyzing every detail, and it occurred to me that the pixel art in-game looked like shit. Some pixels looked okay, while others were more like rectangles than squares. I think this was a lot more noticeable because I put a 1 px black outline around all of my enemies.
I did a lot of googling, researched some pixel perfect camera assets, and scared myself shitless that I didn't plan for this and wouldn't be able to make it work. After fiddling with settings and third-party stuff for a couple of hours, the art that I had spent so much time making look crisp and clean still looked like garbage. Considering the fact that I'm hoping for sponsorship for this game, I almost felt like throwing it out.
But I persevered, and managed to get everything looking sharp.
For any who are interested, here are the settings I had to tweak to make sure everything rendered properly.
In my sprite's import settings, I set the Pixels Per Unit (PPU) to 100 (this becomes important later), set the Filter Mode to Point, and the compression to True Color.
These definitely play an important part, but they're pretty easy to figure out. The next part took some tinkering.
The key to sharp, squarely rendered pixel art in Unity, is to ensure that the vertical resolution of the game, the camera's orthographic size and the sprite's PPU and scale are compatible.
Basically, you have to make this equation true: R/P = O (where R is vertical Resolution, P is PPU, and O is orthographic size).
In my case, I have a vertical resolution of 600, my sprites have a PPU of 100, and so, I set my Orthographic size to 6 (600/100 = 6).
This got things looking better, but, I had one more thing to sort out (and this was my most important lesson).
Stupidly, when I was creating my art, I didn't scale each piece relative to each other, I figured I would just scale the gameobjects as needed. Nope. Big mistake. My zombies had a scale of 1.73..., my bike had a scale of 3, my player 1.5... Needless to say, this resulted in crap graphics.
I've found that, generally, any power of 2 scale will work fine, but in some strange (and by fluke) cases, scales like 1.5 also work. So, I had to rescale all of my sprites and tweak my physics and variables to account for the new scale. A lot of work because I didn't have the best foresight.
Here are some before and after shots of the motorbike:
Huge difference, right?
So, the moral of the story is: Create your art to scale if you're using pixel art.
Also, the other day, because some of you said it would be cool, I started experimenting with enemies whose limbs could be shot off.
I'm on a different machine right now, so I can't share examples of the experiments, but I think they'll turn out nicely.
Each limb of certain enemies can be shot off, and, if killing enemies with shotguns, they'll explode (into all separate limbs) upon death.
Each limb will have a particle system attached which spews red pixels from it in a very excessive anime/kill bill style. The particles will also collide with other game objects, which gives a nice effect. There will be lots of blood.
As an aside, I was lucky that 2d particle collision was JUST added to Unity in the 5.3.5 release in May (though the physics around the collisions still seem a little buggy).
Lastly, tonight, I've been doing some more UI design, and if anyone would be so kind as to share some constructive criticism, I would appreciate it.
Tonight I mocked up the weapon purchase/upgrade screen. Here is the progression:
Player presses a key to open the menu:
Player clicks the AA-12 weapon:
Player clicks 'BUY':
Player clicks on the Damage upgrade:
What do you guys think?