Tuesday, May 21, 2013

Continuous Improvement!

Sorry I have not posted in a few weeks. I just graduated college and I have been moving all of my stuff and getting used to my new life! Thanks for reading my blog though!

First, thank you to everyone that took the time to try out my first game ever, Bomb Catcher. After a few hiccups I got all the links sorted out and multiple people were able to try it. I got a ton of feedback and I welcomed it all. The comments ranged from someone complaining that I did not provide a Linux release to comments saying they could not stop playing! I loved it all and I am extremely happy to see people playing it. After hearing all the feedback I created a list of the topics people suggested I work on.

Topics to Work On:
-Minecart moves too slow
-Unlimited speed boost should have a limit
-Final score did not report properly after first play through
-Need a menu where users can learn how to play the game
-Add more features to the game

For this post I am going to talk about each point. Some points may be longer than others!

Minecart moves too slow!

I agree! I should have fined tuned the cart movement! I got excited when I got the game running how I wanted so I decided to release it. So, this was the first thing I fixed after reading everyone's comments. It was a quick fix and it immediately made them game more fair at the beginning. The only problem that came up after increasing the speed was, why even have an unlimited speed boost (discussed later). Recap, I increased cart speed so the game is more fair!

Unlimited speed boost, why!?!

My original plan was to have a speed boost bar with limited use, but I decided after playing the game for a bit  that I would not include it. The reason I decided to leave it out was because I had played the game so much I knew how the controls worked. I know how to play the game, I know all the secrets to the game! I know I got used to the controls while testing that I thought they would be good for everyone and I was wrong. As of now, I have not finished working on the speed bar(that is what I am calling it). The bar is visible and (as of now) is on the right side of the game screen. It is a bar that will deplete over time when using the speed boost. It will also recharge after a bit of time. I think adding this feature along with increasing the speed of the cart will allow more strategic gameplay.

Why won't my Final Score update?

This is probably the first problem I noticed and other noticed as well. The final score would not update after your first death. I could not have that happen! I wanted people to compete for higher scores! I wanted to fix that pretty quickly but I was not sure how to fix it. Reading through all my code I realized I just needed to destroy the game object that held the final score information after the game restarted. I read online using the Unity Reference guides on how to do this. It was very simple and after a couple minutes of some trial and error I got it to work properly. To further describe the problem, I save the final score data in an invisible gameobject that does not get destroyed when a new level loads. The new level is the Game Over screen. What I did was added a line of code that destroyed the invisible gameobject when the player decided to play another game. This allowed the gameobject to be recreated when a new game started and the new final score to be preserved.

How do I play?

I hear you! I know I mentioned it in the post but what happens if people don't read it or if they pass the game onto others? This week I added a Main Menu and an Instructions Menu. Both extremely simple and too the point. As mentioned before I am not great at art and I do not try to act like I am. So I put together a plain(ish) menu but it gets the job done!

Add more features, please!

Adding features is not really a complaint about the game just a request. But I agree with doing it. I think adding features is a great way for me to practice building better games. One feature I have started to add is a life token. It allows the player to gain a life. They spawn randomly and only last a certain amount of time. If the player does not retrieve the token then the player will have to wait for another token to spawn. I have played with the idea of more than one token but I am not sure what I will be doing.

-Dan

Thursday, May 2, 2013

Finished my first game!

Hey all! I finally got a few hours to work on Bomb Catcher and I finished it. Well, I think I might add to it but the first version is done. I think it turned out well and I have had fun playing it. Here is the link to my public Dropbox with the folder inside: Bomb Catcher

Controls:
There are three controls.
Left arrow(or "a" key) = moves cart left
Right arrow(or "d" key) = moves cart right
Space bar = speeds up cart

I hope you guys and gals try it out. Any criticism is great and I can post all the code if anyone is interested.
**I have notice on some computers the lighting does not work or seems not to work. Does anyone know why this could be? Thanks

Example of the lighting problem.


Now for some information and problems I ran into finishing up the game, there were a few. First, I had trouble importing the cart I made to Unity. Secondly, I had to learn how to save data in one scene and then use it in another. Lastly, I had trouble using data from other scripts.

Importing My Model
I created my cart model in Google Sketchup. Now, I understand this is not the best program to use to model but when I was in High School I used to make things in it all the time so I knew how to use the program. I wanted to get out my first game soon so I did not want to take the time to learn how to use another 3D drawing program. I finished the model and tried to export it and I ran into a problem doing that. Unity likes FBX files so I had to find a converter that converts Sketchup files to FBX files. I used one from Autodesk(I do not remember exactly). It worked and I got my model into Unity. But when I attached my movement script to the object it was not moving how I wanted. I realized the model's axis were different then Unity. I looked online to find a solution and ended up using a empty GameObject and made it the parent to my model. I attached the movement script to the GameObject and my problem was fixed.

Accessing Variables from other Scripts
I have a couple if-statements that I had checking certain variables to trigger events. For example, i was monitoring the number of lives the player has. To do this I needed to access the variable from another script. I had no idea how to do this. Well I knew I could use static variables but I have read to try to avoid those. So I went to the Unity3D subreddit and I asked. I had some answers within a few minutes. I was sent to a website called Unity Gems. They have tons of tips for beginners and answers to common questions. Reading through I found the solution to my problem.

Saving Data From Scene to Scene
This problem came about when I tried to show the players score after they died. I change scenes when the player loses all 10 lives. So I created another empty GameObject and I added it to the scene. Looking through the Unity Script references I found a command that tells the object to not be destroyed. So using the information I learned from accessing data from other scripts, I save the player's score when they die. I do not destroy the object. When the new scene loads I access the script and display the final score to the player. It took me sometime to finally get it to work but I learned a lot in the process.

Here are the links to my reddit post and the Unity Gems website
My reddit post
Unity Gems

-Dan

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

Thursday, April 18, 2013

Paused old project, started a new one!

Again, I have not posted in awhile, my apologies! I blame school though. I am almost done with my final semester and I am ready to graduate and move on with my career! But, you guys are not here to read about that. For my update today I want to talk about my project, "Bomb Catcher." The title is tentative and I do not like it but it works for now. 

I think we all have this amazing idea for a game that we all want to make or have made one day. Like most of you I have that same idea and I would love to make it. But, I realized I was jumping in a little to deep of water for my skills. After reading countless articles on how new game designs need to think small and finish something first before they move on to bigger projects, I decided I needed to do the same. That is where my new project comes in.

A few of my friends here at Virginia Tech are in a class where they were tasked to design a simple game using a microcontroller and an accelerometer. I talked to them about the game and I thought it sounded cool and simple and I said "What the hell, Ill make it!" I decided that I would use Unity and I would code in C#. 

The game is simple. You control mine cart. The cart can move left or right. You can increase the cart's speed for short bursts. A cannon at the top of the screen shoots cannon balls after it moves. The cannon can move left, right, or it can stay in the same spot. The cannon can move random distances based on its location on the game screen. Once the cannon ball is fired you must catch it. If you catch it your score increases, if you miss it and the bomb hits the ground you lose a life. You have five lives to catch as many balls as you can. After a certain amount of catches the cannon increases it speed. If you lose all five lives then the game is over and you must start over. Simple enough right?

Here are a few pictures of my progress so far. 

These are two views of that play area. The bottom is actually what you will see when you play. The top is an iso-metric view to see how I made the scene.

The cannon fires a prefab. The prefab right now is just a sphere with a metal texture  Last night, I added a particle emitter to it. I want it to look like a spark trail(I think).

This is the model I am working on for the minecart. I have 0 experience with 3d modeling. This is my first attempt!


If you have any questions feel free to ask! Hope you like my progress!

-Dan 

Wednesday, April 3, 2013

I am still alive!

I have been extremely busy with school lately and I have not been able to put as much time into my game design. I have worked on it some though. I am graduating in a few weeks so I have been flying out to different companies or interviews and during that time I like to work on my project. I have been trying to find the best way to work on my overall design and from the internet I found a lot of people use Google Docs so I have found a design template and have started filling my ideas in on and I have put it in the cloud! Hopefully I will have an update soon for the blog!

Saturday, March 16, 2013

Player Control: Basic Movement and Camera

Over the past couple days  I decided to work on camera controls and player movement. I wanted to get this done so what ever I work on next will be more enjoyable for me to roam around in or look around at(since I like completing visual goals).

I first wrote a simple script in C# that allowed me to move a box with the W,A,S,D keys. I first version of the script just moved the transform using Vector3 calls. What I mean by this is the transform would just move instantly one space in whatever direction I told it to. This was basic movement but it would not work for my final product. Deciding this would not work for me, I went to the internet and found a simple script on the unity reference pages that allowed me to move my cube much like a car. Using forces this allowed for acceleration and smoother movement. Again, this eventually was not I wanted but it was fun getting something to move and learning more about Unity and scripting. I dropped this script completely and decided to start over!

Camera 

When I decided to work on a new movement script I started with my camera. For my game I want to have a third person camera. I like third person and I find most of the games I play are in third person. I made a list of the camera features I wanted and started working on those.

Camera Features:
-Zoom In/Out
-Rotate around player
-Follow behind player while player is moving
-Snaps to player when character decides to move
-No clipping through floor/objects

With this list in mind I started with the Rotate around player goal. There are several great references online that allow me to get a simple script up and running in no time. Of course, I needed to change a few parameters to make sure the camera fit my needs. I think in about an hour I had a camera that would take a transform target and allow me to move around the player with certain restrictions(like not completely under the player). At first, to rotate the player, you had to use the left mouse button but I changed to allow both or one of the mouse buttons using an "or" statement. Next I worked on the Zoom function. I wrote the code so the player can use the mouse wheel to zoom in/out at their will. After a few hours, I had a camera that followed the player and allowed me to look around. It was awesome I was so happy. The next task, no clipping, was a different story and at first I said "screw it."

Jumping, Spinning, Walking, Running, and "Strafing"

So I decided to skip the camera clipping function and move on to player movement. I went online and found a free character model with some basic animations. I wanted to have something visual to look at. To start with character movement I looked at unity references online and decided to use a character collider for moving. There are two functions for them "simple move" and "move." I use "move" for my script since it allows the most options. I also used the Input Manager that Unity has to keep track of all of my controls. I started working on moving forward and back and rotation. That was simple. I just applied the values that are returned from a ButtonDown command and put thoses on the which axis I needed for that movement. I also worked on making sure the player model had to be on "ground" first before these movements could work. For running, I added a speed modifier to allow me to move faster when I toggled a button. Jumping was a little more complicated. I checked to make sure the player was on the ground and then I added a timer so the player could not continually jump. This took me some time to get working and I still am not perfectly happy with it but its not bad right now! I have strafing working but it does not look good with the animations so I will probably work on it more when I get a better model.

Right now I am working on a Season Script so I can make changes to the Game Time script. I want to change how bright the sun can get and how long the days are and maybe add particle effects later or wind. My next post might be about that but I do not really know!

Dan

Thursday, March 14, 2013

We have Day and Night!

Today, I worked on getting a day and night cycle running for my game(I like working on visual things first, it is more rewarding!). I am pretty happy with the outcome. I will go into more detail below but here is a brief summary.

There are two scripts used for the day night cycle. One controls the sun's properties and the other controls the time of day and rotation of the sun. The in-game day can be however long I want it to be, it is changeable. I can keep track of how many in-game days, months, and years have passed. The sun's rotation speed depends on how long the day is. I also added a Skybox that changes depending on the time of day. The time of day, for now, starts at 12pm and lasts for 30 minutes.

Detailed(With Pictures!)
Ok, so I started out writing a general script to keep track of time and to rotate a direction light in Unity. I use Time.deltaTime and store it in a variable and use that to keep track of days, months, and years. I use a simple Transform rotation to rotate the direction light on the x-axis. At this point the light rotates around the scene like an actual sun.

Fig 1: You can see the direction light in the upper right-hand corner. It is rotation and projecting the light flare on the lower left-hand corner

I wanted to have a more detailed system so I continued coding. I wanted to change the brightness of the sun every day and I wanted to add a Skybox.

To get different brightness settings every day, I created a script for the direction light. The script sets random values every day. The Game Time script I wrote earlier uses these values and adjusts the sun's brightness based on the time of day. For example, at noon or 12pm, the light is the brightest and as the day goes on it gets less bright. I really liked how this turned out and as little as the random values of brightness change I like the added effect.
Fig 2: This is just the direction light(sun) setting.

The Skybox at first was just one scene with clouds. I did not like it so I went online and found a new shader that allows me to add two scenes. One scene is a night sky and the other is a day sky. Using this new shader, I code in the Game Time script how it should blend the two scenes by time of day. I really liked how this turned out. I think it is beautiful! I feel like the world is coming to life, even though there is no world, yet!
Fig 3: The day scene skybox. The cube shown is to look at shadows.

Fig 4: The night scene Skybox. The cube shown is to look at shadows.

Side Note:
I added a moon with the same functionality as the sun but I did not like it so I did not keep it in my final setup. I like the night sky too much. Also, with my Game Time script I can add events depending on the time of day!

I will try to keep my thoughts organized on these posts. I cannot promise though. If anyone has questions, ask away!

The Begining

Starting today, I am going to write about my game development adventures! Hopefully, crossing my fingers, that I keep up with this. I want to have a spot to discuss all of my failures and successes while I design my first ever game. I may not ever finish the game or make much progress on it; however, I do think it will be great to look back at my progress. This is my first post on my new blog and I will hopefully post later tonight to update everyone on where I am now.

If anyone is interested in what I am using for my development here is the list of tools:
Unity 4.0 Pro - Game Engine
C# - For scripts
Gimp - Open Source Photoshop
MonoDevelop - C# IDE

That is it for now! More to come!(hopefully) Dan