Saturday, 17 October 2015

Prototyping

Once you've designed the game and researched what you want in it, the next step is to start prototyping a few mechanics to get things going. Prototypes don't need to be stylish or flashy, they simply need to test a mechanic and show it working. The entire point is for the prototype to be quick, simple and rough around the edges. I took the separate mechanics of my idea and wrote down a rough plan of what needed to be done for each one, then went to work adding bit by bit to the prototype.

I started by creating a character controller and mouse look because the character is the most essential part of the game as that's the players entry point. Once the character was in place, I focused on adding the bullets and gun, which went with the character, then set bullets to destroy in order to keep the scene and hierarchy tidy. With the bullets added, I needed something to test them on therefore the next mechanic and item I worked on was the targets. To create these I recycled and modified the interpolation script I was taught how to construct a few weeks previously. I used it to create targets that rise up only once and others which bounce between 2 points. At some point I'd like to implement a pool manager to deal with bullets, bullet holes and especially the targets I'll being creating as this will improve the efficiency of the game.
General shot of prototype

At this stage I was happy with the amount of mechanics that had in my first prototype, so moved on to create a map prototype. It's a simple layout that shows how each player will be positioned opposite each other and locked into separate sections that unlock over time. As it's only a prototype of a straight street, there isn't a huge amount to look at. However it does it's job of showing what I want the game area to like look, which is all it needs to do.

Street layout prototype

I plan to do a quick run-through video of my prototype and will get to it once I've learnt more about how to use OBS.

Thursday, 15 October 2015

UVW Mapping and Texturing

Practically every game contains objects and those objects need to have a texture. Applying a texture is a multi step process starting from the creation of the primitive object. Before we could create anything ourselves we were tasked with unwrapping a few objects that had been created to awkward scales and angles. Applying a checkered material to the object allows you to get a feel for how the texture will apply to the object and gives you a chance to change things round. Each polygon must be using the same scale as all others, else when the texture is applied it will become distorted and look wrong. Objects like cubes and cylinders are simple to unwrap and re-size, however objects like cones are a little trickier to sort out.
Re-sized objects from challenge

Once I had finished with the practice challenges, I was tasked with creating a few objects myself, then unwrapping and texturing them. The objects were: Coke can, dice, wine bottle and a crate. I started with the can as it seemed more interesting than the dice or crate but not as complex as the wine bottle. I started by making a cylinder and to make it seem more realistic I inset the top face and extruded it slightly, then chamfered the edges to round them off. When I was pleased with the shape I added the UVW Unwrap modifier and opened up the UV Editor to see how the object would look when unwrapped. Initially the mapping was confusing and messy so I used the unfold tool to make everything neater and easier to understand. The UVW template was then rendered and saved.
UVW template rendered and ready for texture to be added

The template was then imported into Photoshop so I could place the textures on it. The template works as a placement guide, allowing me to see where colours and pictures will appear on my objects once imported back into 3DS Max. I found a Coke can label and fitted it over the unfolded cylinder section of the UV, then proceeded to find a metallic texture which went over the can ends. For a little detail I looked up ring pulls and added it to the top face of the can.
Finished textures placed onto UVW template

When I was happy with the placement of each texture, I saved the image and placed it onto the object back in 3DS Max. The UVW was mapped back onto my can putting everything exactly where it was set in Photoshop. The result was a nicely textured can that can be used as a prop in game scenes.
Can with texture applied and finished

With the can complete, I set to work doing the same for the other 3 objects. The crate and dice were simple cubes so unwrapping them and adding the textures was no trouble.
Completed dice

Completed crate


The wine bottle was slightly more difficult to do and came out looking a little strange at first. To begin with I feel like I made the bottle slightly plump at the base rather than thin like it should really be. I do like the shape though and it could be used in a game for an alcohol bottle of many sorts. Secondly, I forgot the cork at the neck of the bottle, which I feel makes it more realistic, and the textures I applied didn't look very good. Therefore after I made the initial version, I copied it to try again. My second attempt looks far better and overall more realistic.
Improved wine bottle (left) and initial version (right)

Once each object was textured and I was satisfied, I set them up together and rendered the scene in it's entirety. I'm very pleased with the look and feel of each object, but it's definitely something I'll need to practice and work on if I hope to produce more detailed and higher quality objects/textures in the future. Unwrapping and texturing objects like this and even more complicated ones is quite daunting for me but it's a skill that will come in very useful so I'll spend some spare time practicing it and seeing what I can create for any games I produce.
Completed scene

Wednesday, 14 October 2015

Improving Catapult Mechanic

Whilst the catapult worked perfectly well, a few improvements could be made to make it more efficient/rounded. My first improvement was only allowing the object to aim and jump if the mouse is clicked whilst hovering over the object. In order to do this I needed to register the mouse position upon the person clicking. I set a ray cast to fire from the camera from this point and to see if it hit the box. If so then a Boolean 'hasClicked' is set to true, else it remains false. If the Boolean is true then the player has clicked on the object so can now fire it, otherwise nothing happens.
Object with aim dots showing path

The second improvement was altering the force applied depending on how far back the mouse was dragged. So the object can perform either a large leap, small hop or anything in between. To solve this issue I was required to use a few simple projectile physics equations that determine the distance based on the velocity and gravity. Once the equations have worked out the distance travelled, the position of the dots could be adjusted to create the new flight path of the object. As all of this is in a method called within update, the path will update in real time based on how the player is angling the shot.
Physics equations applied

This way, clicking on the object and moving the mouse to aim and apply force gives the feeling of pulling something back in order to fire the object forward.

Monday, 12 October 2015

Angry Birds and First Person Shooters



In week three we started doing something I've been looking forward to: first person shooters. Whilst we covered an Angry Birds style catapult system as well, the FPS mechanics are what I definitely want to use in my game, so learning about it helped me broaden my ideas for the mechanics I could use. We started the catapult/trajectory mechanic first, so I'll cover that to begin with. The objective was to create an object that, when the mouse was clicked and held, produced dots to show the trajectory of the object. Upon releasing the mouse button the object would be propelled along that path shown. In order to produce the trajectory, we needed to use two equations which calculated the distance the object traveled in both the x & y axis and project the dots along this path.
Trajectory equation code

For the first person shooter project we had to put a first person character controller into the scene and to that we attached a bullet script. This script very simply creates a bullet game object and applies an impulse force, which uses the objects mass and gives realism in the trajectory of the bullet. Initially the code was set to fire on every mouse click, which produces a semi-automatic gun. I changed mine to fire when the mouse button is down which creates a fully automatic gun, albeit an incredibly fast one which I'll need to tone down. To stop the scene from filing with useless bullets after they're fired, the bullets are set to be destroyed after 3 seconds. A pool manager would be far more useful and efficient so I'll work on that in my spare time.
Bullet fire code

In order to make the bullets fire from an appropriate position on the player, a gun script is needed which sets the firing position of the bullets to a specific place. In my case I used an empty game object attached to the right side of the player. This makes it look as if the player is firing a gun in their hands. For fun I added a second bullet spawn to the other side of the player to appear like the player is dual wielding the guns. These scripts are something I'll be playing around with a lot in order to get the best feel for my guns in my game.
Shooting block tower

Saturday, 10 October 2015

Mood Boards

Once I was happy with the concepts I had come up with, I moved onto the 3rd stage, research. This involved looking at all the ideas I'd had and thinking about how to develop them further, into proper mechanics/objects. A great way to do this is to create a series of mood boards; a page full of images that you can use for reference when designing your mechanics/objects. For my mood boards, I choose 4 different ideas to make them around: Western High Street, Guns, props and targets/power-ups.

For the Western high street idea, I gathered images of straight western main town roads and the old wooden buildings dotted along them. I got a nice mixture of real life town streets, movie set versions and a few from games. Using a variety like this will show me what the most popular definition of 'Western High Street' is, allowing me to create the most realistic environment for my game.
Western High Street ideas

My second mood board focused on the weapons I was hoping to use in the game. Since the setting is a an old Western one, I wanted to use authentic weapons of the time. This meant fully automatic weapons are pretty much out of the question and single shot ones are what I needed to look at. To have a western dual flare to the game I wanted to have the players use revolvers because they were the staple handgun in the era. I had an idea to possibly add a rifle as a power up that allows zoom and has more ammo in it, so looked up a few designs for those as well. I got a mixture of both real life and model pictures, so I have an idea of what to aim for in the long run.
Gun ideas

With the setting and weapons researched, I wanted to get some ideas for a bit of detail to the scene so created a board of props. The 3 things I had an idea for were barrels, crates and some plants. These aren't a huge part of the game but adding them in will make the scene seem more realistic and they can also be used to hide targets behind. I got a real life image of each thing to see what they would really look like and then checked out some 3D models/game versions to see how similar the 2 were. Each were very close in appearance, most likely due to the fact that there never is much variety in the appearance of barrels and crates etc, however it's always good to double check and get references.
Prop ideas

The final board was filled with my ideas for the targets and power up icons. I chose generic red and white ringed targets because they're recognisable to people and will be easy to see in the game scene. I also wanted to add a few different things into the scene which may not be as obvious to shoot but will still give points. For this I was planning to use some props, such as the barrels, or even add other new objects such as scarecrows or lights. For the power ups I wanted a variety of things to keep the game as interesting as possible. I obtained images for:

  • X2 points(doubles points for short time)
  • Explosives(grenades or dynamite with AoE damage)
  • Dual wielding revolvers(double the ammo/negate reload time)
  • Rifle(more ammo and can zoom)

Each of these will have a chance to randomly appear in the scene and the first person to shoot it will be given that power up for a short time.
Target & power-up ideas

Thursday, 8 October 2015

Polygon Modelling

In the second weeks design session, I learnt to how model polygons into something more than just a primitive object. I learnt about tools such as: extrude, inset, bridge, chamfer and connect. Extrude allows you to move a polygon within or out of the rest of the object, creating an extrusion. Inset creates a smaller polygon within the selected one, using the selected polygons vertices as a shrinking point. Bridge takes two selected edges and bridges the gap in between with a new polygon. Chamfer creates new edges on the selected area and can be used to smooth edges. Connect will create a new edge from one edge to another, splitting the polygon they're part of in two.

I was tasked with using all of these new tools to create a house model from a single box object. In order to have a plan to work from, I was provided with a house model sheet that had perspectives of each side of the house on. I attached it to a plane and then duplicated the plane at a 90 degree angle, creating a cross shape. I could then build my house to the correct dimensions using the pictures on the planes as a template. Something else I learnt to do was how to make an object see-through, effectively like a ghost. This was necessary to allow me to see the image through the object and use it as a template.
Finished house model with template in place

Once the house was finished, the next objective was to add more objects to our scene. Since the template had a wall on it, that was my next plan of action, with a gate, pavement, road and lamppost to follow after. Each of these were new objects rather than extensions from the house object since they were more for detail and filling out the scene.
Completed scene with all objects added

Now that everything was finished I could add lighting in order to create renders of my scene. I wanted to use the lamppost as a light source rather than simply have it as scenery. I remembered the use of the spotlight in my work the week before and thought this would work excellently for a lamppost. However when I rendered the scene for the first time, the spotlight was far too pinpoint for my liking, so I changed the spotlight parameters to increase the falloff. This gave a much wider spread of light and made the scene look more realistic. An omni light was added to slightly brighten the scene in general for aesthetic purposes.
Night scene using spotlight on lamppost

Finally I was taught by a friend on how to use a daylight system, which allows me to set the light on my scene as it would be at a specific time of day and month. This allowed for much easier control of making the scene appear as I liked it and I'll definitely use it again in the future.
Shot of back of house during daytime

Wednesday, 7 October 2015

Physics Debugging and Manual Interpolation

Following up from Monday's session, we implemented debugging to see how Unity controls the change in velocity. To do this I added a max speed which, when reached and passed, lowered the speed back below the maximum. The speed was not lowered to a constant however and continues to increase meaning this process happens very quickly multiple times a second. To show this, a line is set to be drawn that shows the direction and magnitude of force. This line appears to vibrate/shake rapidly when the player moves which is the program constantly adjusting the velocity.
Cyan debug line in physics scene

Another thing I added to this weeks work was creating manual interpolation rather than have it bounce back and forth of it's own accord. To do this I only needed to tell the co-routine that it should only operate when a specific button is pressed and held. This sort of mechanic could be used for moving platforms and can even be set up to activate the interpolation upon a single button press, allowing you to make elevators.