Tuesday, April 23, 2013

Gameplay, Sounds, and Problems!

For this week's update I am going to talk about some of the problems I ran into, how I fixed them, show some gameplay, and discuss sound!

Problems Galore!
Well mainly one problem. I got the game up and running fairly quickly, quick for me, and I was pretty happy. When I started really coding the cannon that is where I ran into some issues. First, I had to figure out how I was going to code the random logic for where the cannon would move too. The cannon randomly chooses to move left or right. Once it chooses a direction to move in it measures its distance from a right or left collider and that distance, minus 1.5 units, is the max distance is can travel in any direction. The cannon randomly chooses a point and then creates a new position to move too. This is where I ran into problems!

The cannon, at first, was moving way to fast! It would just jump around to the new positions. I wanted it to move gracefully! So I went to the script reference guide for unity and I found two useful terms. Vector3.MoveTowards and Vector3.Lerp. I have used MoveTowards before but never Lerp so I had to do some research. After a couple minutes reading about Lerp. I decide to try and implement it. I had some trouble at first but once I simplified my code down to just moving the cannon once I got it work. However, I did not like it. The cannon did not move at a constant speed and I wanted it too. I switched from Lerp to MoveTowards and got what I desired. One more problem to solve! The cannon still jumped around and I wanted it to get too its position before it moved again. For some reason figuring out this simple logic took me hours! I finally figured it out though. I had to take a couple nights off from coding but I got it to work. I was not saving its last location and I was not waiting until it got to its new position. Once I added the code to the check this it started working. The picture below is 2 seconds of gameplay. The cannon is firing bombs and I am moving the box to collect them.

Short gif of me playing the game. The cannon fires a bomb and I use the cube to catch the bomb. I have created a cart to use but I am having trouble implementing it. Sorry for the poor .gif quality!

Now you might be wondering when or how I added the firing mechanic, or maybe not, but I will explain. I added a firing function to my cannon script. Once is gets to its new position the cannon fires. It creates a prefab. The prefab I created is a sphere with a metal texture on it. I also added a particle emitter to it. I added a script to the ground(the brown layer) that checks for the prefab. Once the bomb prefab touches the ground the bomb is destroyed and the player loses one life.

The picture below shows the new placement of the number of lives and player score. I used GUI style to achieve the simple look and color.

I did not change too much to the score and lives with GUI style but I did change them a little. Lives in now a reddish color and is more visible. I moved the score to the other side of the screen and more visible.

Sounds and Music!
I have been using  Freesound for all my sound needs. I am not a sound engineer or designer(not sure what the proper term is). I have found a few clips that I want to use for the cannon firing and the bomb explosion. I am still trying to find a good clip for background music. Any suggestions on where to look? I also have some sounds that I want to use but I am trying to figure out where to use them in the game.

Lets play!
In addition to fixing the cannon problem I also added another scene to my game. I am calling this the Game Over screen. Once the player loses all 5 lives the game is over and the player is sent to this screen. If the player chooses to play again they can click the button and the game will start over!

The screenshot of the Game Over screen. It is extremely simple and not very pretty but it gets the job done! 

Thanks for taking the time to read! I am making slow progress but I am excited to finish it! If you have any questions please feel free to comment.

Dan

2 comments:

  1. If people are reading your blog it's okay to assume they're interested. You have my blessing. :)

    ReplyDelete
  2. You are right, I will try not to write like that and thank you!

    ReplyDelete