Tuesday, 14 January 2014

Unity games



 I started this first project by following a tutorial found on youtube.
as my knowledge of javascript, and coding is general is limited i found this a great help to creating the game.
 Firstly I had to put in some controls that allowed me to move the ball around.
this code allows me to move along the horizontal plane using the 'A' and 'D' keys; which is the basics for a 2d game.

in the scene view I put in some objects, the ball and the large rectangle.
the ball is the player and the rectangle is the ground.

the above script was applied to the ball to give it the ability to move along the X axis.
______________________________________________________________


















After i had the ability to move along the X axis, i needed to add more functionality, so the ability to jump was added. Using the 'w' key the player object/ball was able to raise by 8 on the Y axis.
originally there was an issue where you could jump indefinitely, but thanks to some "if" statements it was made possible to only give the 'w' key functionality when it was in contact with the ground.

















i then set the camera to always focus on the ball and move with it accordingly, so instead of a static camera the focused on a single area, the camera now followed the ball as it moved.
after the ability to jump was implemented and the following camera i also added a skybox to the main camera giving the game a better look, rather than the basic blue background.

____________________________________________________________

i had to add a function to reset the game if the player fell off the platform.
when the player get's lower than '-10' on the Y axis they are returned to the start of the level.
this prevented the player from falling indefinitely.

I also switched the light from a point light to a directional light.
unfortunately the free version of Unity doesn't offer a point light with shadows, and the point light was only illuminating a single area.
the directional light (or as I named it '_sun') has the ability to give objects shadows, and applies to the whole scene, making it a better solution than having multiple light throughout the level





I added a coin collectable into the game to add more of a goal for the player to gain. these coins disappeared on collision with the player, and were later changed to give a score when collected. 

__________________________________________________
i added a rotation animation to the coin so that it spun and slightly moved up and down in a looping fashion before it was collected.

Particle effects were added to the coin, this made firework like visuals to appear for two seconds when the player collided and 'destroyed'/collects the coin

Alltough the coins seemed to be collected on collision with the player, they didn't actually have a real function, because of this, a score system had to be implemented


A new GUI was implemented to keep track of the score when the player picked up a coin.
however this function if broken at the time this part of the post is being written.
when the coin is turned into a Prefab to use around the level in the scene view you can place multiple coins at different areas within the level.
however when the game is played the coins turn into a single coin and give points = to the amount of coins used in game.

for example if i were to put 5 coins around a level and played the game, there would only be 1 coin, but instead of a single point, it would give me 5. 



This is the point where the web tutorial ended, so I decided to browse the unity assets store to find something nice to improve the game.
I found a nice terrain to add in to make the game seem more in depth.
instead of being a brick wall floating in the sky, now this new terrain game it a feeling of more depth and a more 3D looking environment.










I toyed with the idea of moving the game over to a 3D environment as i was completely stuck for ideas.
and it somewhat worked, although i couldn't get the camera or movement to work the way i wanted, so i gave up on that pipe dream


i could have put in a final little ending for this game, although due to time constraints i was unable, despite it being as simple as modifying the code for the coins and placing it on a platform that sends you to the next level.


______________________________________________________________

 3D game:

with the loss of my original 3D game idea i had little over a week to start and finish a full game, in hindsight not the best plan, but i was determined to at least have something that functions 
So after a few "fun"larious discussions with a few people i had my idea.
the adventures of Jizz-e the pimp, now i knew i wouldn't be able to get a full working game start to finish out, but i atleast thought i could get something done.
so i got to work, with a simple beginning, and unlike the previous game, unity has the character controller needed for 3d First person games, so i was able to just add that and be free from messing with the camera.

i put in a little light and a floor and you were able to move around,
...on a block with nothing to do in the middle of nowhere.

still, another easy thing to do i learned from the last project was to just add the skybox, so i threw on the nice night time one.

now this game was to be a little different from the basicball one, here you needed to actually kill stuff.
so this melee system was worked in.

However, there was a fatal flaw i could hardly work out.
i toiled and toiled trying to find the soloution
 then i found my answer:

i had forgotten to capitalise the "U" in "Function Update ( )"
so despite casing me half a day in headaches, that issue was over. 


i added in a cylinder to become an enemy and that was out of the way.
-----------------------------

With the melee system functioning i needed to have a weapon, and what other weapon would a pimp use other than a pimp cane.... aside from a gun, but that's not important.

i modeled this cane in cinema4D and at first it had issues when importing.
the textures only showed on the inside of the model.

i tried everything, exporting to FBX or keeping it as a c4d file.
in the end i decided to move on a find a solution later.

at this point i changed the light from a point light to a directional light to allow shadows to render.

then i added a crosshair, it has a little flair to it with the dollars, but i wanted it to be a little over the top.

And atlast, i was able to fix my imported model, the issue was easily solved,
all i had to do was "Reverse normals" in c4d to make it render properly.

i animated several functions, so it had a movement when you walked as if you were using the cane to walk with, although not really fluid, it worked slightly well.

there was also another animation for sprinting when you hold shift, although that hadn't come out right, and a sprint function didn't even work.
still you can hold shift to see this animation.

and finally the attack animation, i wanted a swing that hit with the end of the cane, and it's there.
although there is an issue where the animation doesn't play over other animations, an issue i tried in vain to fix, but i gave up as time was running short, so then i moved on.

i did also try to get the attack damage apply mid animation, but that didn't work out, so i scrapped that idea.

i got skankzilla out of the way, using a model i found online, then i edited the texture and changed the model slightly. and there you have skankzilla

after placing her in the game i applied a mesh and she was ready to be worked on
 (although i completely forgot to add the enemy script to her)

with that done, i created the terrain.
i wanted to have a slightly different feel in a few environments  so i added a few in
  • a grassy lane
  • the woods
  • canyon
  • dead plains (dead grass and red and orange)
  • the final zone
i think they did work quite well, although they do feel empty



 then i had to edit the actual trees, and good god it took a long time.
at first i thought i could just brush them in using the terrain options.


but there was a problem.
once they were brushed in they didn't have a mesh so you could walk through them, combined with the fact that they dont render as anything other than an unlit 2d image when you were far enough away.

so i had to change it up and add every single tree manually, and that took a long time

----audio-----

thanks to dayrls intervention we all had to add our own music and sounds to our games.

me and tristan recorded a variety of sounds, and i also had various music that i had made in garageband.
so i was able to add them in.

although most of the sound effects were just from random things i thought i should record just in case.

most of the sound effects i did get seemed pointless and unusable.
but a few were salvageable



i then got down to trimming the sounds down from their 30 second audio tracks.
and ended up with a few sound effects of about 1-3 seconds long
infact i was able to get more use out of sounds of coughing or tristan yawning thanks to editing effects of audacity.
i applied them to the game, but some were very problematic, and still as it stands the game lacks the required amount of sounds... still 1 day to hand that bit in, i can still do it... i hope.


------------------------------things i forgot to mention----------------------
there were a few things that deserve honourable mention.
first of all is this bridge.
i really love the way that this model came out, i wasn't expecting anything amazing, but from what it turned out to be i think this bridge worked pretty well.
there are 3 across the map that lead the player to more of the jewels.

 I did take the score system from my basic ball game and apply it to these jewels, it was my hope i could change it up to become ammo for the weapon shown. (dollar wad) so that if you got a 1 for score you would have 1 shot of ammo to use.
this never came to fuition despite how much the game was driven by this idea.

another thing you may notice in this screenshot is the money.
this is a projectile based weapon that would shoot dollar bills at enemies, although i never had time to implement it.
it does have a nice glowing effect with the particle dollars that float around it.

this torch was also modeled, although i was aiming for something more rustic and bent looking, this seemed like a better idea when it came to having it everywhere on the map.

the fire is created by particles, 2 particle systems in fact, one for the flames themselves, and another for the smoke that rises from the flames.
this also generates light and is one of the only things other than the jewels to do so.




another major thing i wanted to implement was another GUI, a health bar, 
i designed this on myself. and it worked on 10hp per bar (assuming the player has 100 hp to start with)



i'm a little disappointed i was unable to implement this, as i really love the look and feel of the bar.

so that's my "game" i gave it my all as soon as i had the idea, and in the future i'll probably work on it again as a personal side project, until then though final major project time.














No comments:

Post a Comment