Thursday 26 March 2015

Term 2 - Unity Project - Space Enforcer


So this term we were tasked with getting into groups and creating a 'Flying Shooter' game. We quickly decided that our group was going to do a 3D space shooter. We brain-stormed some ideas about themes so we could start working on ship designs. Our theme was that of space pirates. The enemies would be pirates which salvage parts from other ships to make their colossal mothership. The player would play as a galaxy police fighter pilot who is tasked to bring these pirates to justice. In terms of gameplay we decided on having a number of enemies and once they we all destroyed, the time it took would be logged into the high score table.

With the other two members being more art orientated, they took on the roles of concept art, each having a different 'faction' so the final game would reflect the design differences in each of them. In the first couple of weeks while they were drafting concepts for the ships I got down to doing the first gameplay prototypes and mapping out the scene in Unity.

I started by getting some placeholder objects in the scene, a giant sphere to represent the mothership, some crude boxes to be shaped like the players ship. I did all the usual boring stuff like created colliders and lights and then got to work trying to get the ship to move. I wrote a very basic script to make the ship move forward then used a combination of stealing, editing and writing from lots of different scripts I found with similar mechanics to what I was looking for, especially for the camera follow script. The shooting was almost a copy from the scripts we learned in the lesson we had, as well as the second aiming system - which was mouse cursor based. The first being the simple movement I had made with the up, down and rotate commands.

We then had some of the designs ready so I could then replace my basic placeholders with slightly less basic placeholders for the mothership, player ship and enemy drones. At this section was where I started to refine the gameplay and overall feel of the game. I replaced my sunset placeholder skybox with a generic (but detailed) space one. When play testing I realised while flying around the mothership it was easy to quickly become disorientated as it was very difficult to know which direction you were travelling in. I needed some kind of visual cues or at least some landmarks to try and know which direction you were facing. At first I wanted to add a massive planet below and off to the side, but camera view distances made that impossible. That is when I found the skybox I wanted to use on the Unity Asset Store:


This was an important piece to the overall feel of the game because it allowed orientation very easily while still being in outer space. I also did some other 'scene setting' at this point, including a directional light from below to replicate the light reflection for the planet which was not below our ships.

So now with basic models, player movement, shooting done I had to add a few more complicated things. I added some scripts for enemy aiming, with a capsule collider which acts as a cone of vision. When the player enters the collider the enemy bullet spawner on the front of the enemy will face the player (or just in front), then reset to the forward position when the player exits that collider. I found during testing that if the ship was aiming directly at the player then it would have almost no chance of hitting with its lasers. I added an empty game object attached to the ship hierarchy quite far in front for the enemies to shoot at. That meant that at least they could hit the player sometimes. I did look into AI for aiming properly, but not only were we told that there wasn't to be AI in this project, but also it looked far too difficult.

At this stage I needed to make the enemies fly around using animation loops, but in order to do that the mothership model would need to be complete. As my part of the art side of production, I was in charge of the mothership model and textures. The concept designs had already been done, and I knew that it was to be made of different materials so I went about making that in Maya from these references (not made by me):



I started off with the main base disc-like structure and worked my way outwards from there. I tried to keep the poly-count down in this model, but I probably could have gone a bit higher considering its the largest part of the scene.




I used the non-linear bend to get the curves for the outer shell:


Added connector pieces, roughed up the shell 'sails' and added some buildings to the surface:


After this I unwrapped all the UV's, which was a mistake - I should have unwrapped as I went so the UV's would be duplicated with all the different connectors and buildings. Instead of unwrapping 10 different objects - I unwrapped about 40. BIG MISTAKE. I'll never do that again.

Now with the model in place, I could get to animating the enemies on their looped paths. This was quite a long and painful process (I don't enjoy animating that much) but finally got a few done, and looking OK for play testing purposes. I got up to 8 enemies (I wanted 10-15 originally) and I realised the level - even though massive - had become crowded with drones and decided to stop as the game would need to be able to be finished within a reasonable time frame. I've since learned that I could have used a plug-in which allows for objects to follow paths, which probably would have helped a lot, and will use next time.

We did want to have stages to the game initially, almost like a traditional a boss fight. First we would have drones, when they were destroyed the turrets would becomes active and need to be destroyed and then finally the core and the entire ship would be able to be killed. This wasn't possible in the end due to time constraints.

So we had all the core mechanics, flying, shooting, enemies that can kill, move and die. The player movement was still bothering me though, the mouse aiming was too precise and 'easy'. I went back to the first simple aiming system I had - being able to move up and down and rotate - but this time used a controller instead. It changed the whole experience. Now it is fun to play. I re-bound the brake and boost mechanics to the triggers (which took me ages to figure out how the 3rd axis works with the -1, 0, 1) and edited it so that turning speed increases while going slower, and decreases while going faster to add some gameplay. I then added a left and right dodge feature to the two shoulder buttons.

The dodge didn't come out the way I envisioned either. I wanted to (on button press) have the ship move quickly to the side and rotate a little, wait a split second, then return along the same path but slower and smoother, then go on cooldown. I have the cooldown with a co-routine and the movement and direction correct, but not the fluidity I wanted. I could probably do it with a lerp but I couldn't figure it out properly.

Next came to texturing. Now I had loads of issues doing this initially. Even with most of the model unwrapped well enough, creating the textures to be able to tile in game was difficult. This model in game is so large, that from any distance it was really obvious that a texture had been tiled. So after making about 5 different textures in Photoshop, I decided to change my approach. I decided to import the OBJ into Mudbox. All the pieces had separate unwrapped UV's already so I just had to create textures for each piece which was easy enough with layers. I grouped certain types together under materials - buildings, pillars, sails etc. and got to painting all the different parts, adding normal maps also where appropriate.

Projected little windows and gave them added specularity for the buildings:


Layered textures and paint for the alien pillar effect, adding dirt and grime to the bottoms:


Layered 7 different metal and rust projections over the panels to give them a unique and not tiled look:


The base is shiny and of a more alien origin (different than the pillars) the sails are scrap, as well as the connectors and the buildings are more human looking:


A couple of the parts did come out with really stretched textures - like one of the connectors. I noticed the UV's were at a wrong angle. I tried to re-import the UV's only but it didn't work, I don't know why, I'll have to look into it at another time.

I then exported the whole thing as an .FBX and opened the textures in Photoshop. For the textures which I didn't add separate bump and specular maps for, I took the texture, made it greyscale and adjusted the levels, inverting as necessary to make a specular map. Then for the bump map I edited it a little and used the xNormal plug-in in Photoshop to make them into normal maps. I then imported it all into Unity and added the materials and all the textures: 


I added some additional lights in the centre of the ship and some sound effects of Star Wars blasters for the lasers, and some other general motor sounds for the engines. Added scripts for these to change pitch as the ship changes speed.

The scene was ready to take back to get all the others to add their bits: asteroid spawns, particle effects, explosions, menu's, highscore, UI and finished models of the other ships. After that came all the extra parts of the scene: added lights, and atmospheric effects, bloom and general polish, along with a bunch of play testing and value balancing to create the best experience.



During this project it learned loads. You really do take a lot from all areas of design when you make a level from scratch and overcome all the pitfalls along the way (well almost overcome them all). I learned important things like poly counts, organised UV unwrapping, animation paths, how to texture effectively, game balance, level design and lots of other smaller things along the way. Many things I would do more efficiently or just differently next level or asset I would make, many mentioned above. Cool experience and I'm fairly pleased with how it all turned out.



No comments:

Post a Comment

Note: only a member of this blog may post a comment.