Tuesday, August 22, 2017

Week 13 - GAM111 Reflection

Week 13 is the last week of the trimester, and for this blog, I will be reflecting on how I feel about the module as a whole.

For the first few weeks of the module, I admit that I was slacking a bit, as the lectures we had then were re-capping about things we did last trimester, and I thought that I could ease my way out. However, when the submission date of the first assignment got closer and closer, I realized that I should have done a lot more research, added more heart and soul into the assignment, and before I knew it, it was too late for me to put in a whole 6 weeks of work, in 2 weeks, on top of other assignments from other modules. And when I submitted my first assignment and got my grade, I made a promise to myself to not slack and to never leave things or find a way to ease my way out of an assignment. The only way to get through an assignment is to make it seem fun. Like my lecturer said: "Make a game that you want to play as well." And that made sense. If I make a game where I don't like it, or don't want to play it, how can other people like it? How can other people even play it? And these are the questions I asked myself constantly during the duration of the second assignment of this module.

ASSIGNMENT GAM111.1:
The game I made was not good. There were no assets, no color whatsoever, and the mechanics the game had were barely working. After submitting the assignment, I reviewed the work, and looked at where I could make the game much better. And with the lectures that we had after that assignment, if I had the ability to re-do this assignment, I would have made it better. But, the only thing I can do from this assignment is to learn from my mistakes and not to repeat it again.

ASSIGNMENT GAM111.2:
For this assignment, I have told myself to not leave it to the last second, and to make the game enjoyable and something I would play. With these objectives in my mind, it made the assignment fun, and made each requirements, something like challenges or a trophy system in a game. The more you get, the higher your score, and the higher your score, the higher the chances of your work to be displayed on the hall of fame. Another factor which helped me make this assignment turn into a game was the newfound knowledge I learnt that could be used for the assignment, and even in the next trimester.

LECTURES:
I feel like the lectures helped me a lot for the second assignment, and it made me feel really good about the second assignment. We also have somewhat of an advantage for next trimester with the knowledge of the Finite State Machines, and Raycasting. The lectures also allowed me to understand how some game companies add in their own mechanic into the game, like crosshairs changing color when they aim at an enemy, how First-person cameras are made. In general, it makes me look at games, not only as a source of entertainment, but also a source of knowledge and inspiration. 

Week 12 - Workshop Assignment II GAM111.3

This week, is the submission week for this assignment, and the good news is, I have managed to get everything working!

From the previous week, I set a milestone to:
1 - Add at least one more effect to the game
2 - To get the turrets to work

EFFECT:
For the effect, I used a particle system for the enemies, so that whenever they get hit, it would seem as if they are crumbling. The particle effect I used was pretty simple, but it did require quite a lot of time to make. I have added this particle system to all of the enemies, however, one done side about this particle system is that I forgot to change the color of the particle systems to match to the enemy's color, meaning that all the enemies' particle system is yellow (the color of the medium enemy). However, the bright side of it, is that it makes the game look very nice.

TURRETS:
After a few weeks of attempting the turret mechanic, I have managed to get the turrets to work, with the help of my lecturer during class. All this while, I forgot to use the keyword GameObject.Find and GameObjectsWithTag.Find as well. All this while, I've been using...:
public GameObject Enemy;
or
public Transform Enemy;
...this would allow me to set the GameObject variable or Transform variable with the name of Enemy, to the Enemy prefab. However, my lecturer told me that this wouldn't work, as it would get the transform.position of the prefab, other than the one we need, the updated transform.position within the game scene. After understanding this issue, my lecturer told me to go the Unity Documentation online, and search for anything which can be of use. He guided me to look for GameObject.Find, which works, but not the way we need. And eventually, we found a keyword which went along the lines of GameObjectsWithTag.Find, which finds any GameObjects within the scene, with the a tag you have set it to. Implementing this in the code finally made sense to me, and to the program itself. All this time, the turret was looking at the transform.position of the prefab, other than the updated transform.position of the GameObject within the scene. After getting this turret mechanic done, it felt like a great deal of weight have been lifted off my shoulder.

ADDITIONAL EFFECTS/ACHIEVEMENTS:
Throughout the whole week, and last week, I managed to get a menu system working for the game. I have a main menu, the game scene itself, a game over screen and even a controls screen, which briefs the player with the objectives, the enemies and how to play the game as well. Alongside completing the UI and menu system as a whole, I also added a currency system, and assets from the assets store and the internet for the fonts that I have used. Having a different font other than Arial, and adding in some low poly trees, rocks and fences, made the game seem very cute and very simple, which reminds me of some games that have been published on the Google Play Store for Android, or the App Store for iOS.

RESULTS:
Overall, I feel very happy with the game I have made in the past few weeks. I have managed to make a game with more than one type of enemy, a currency system, a turret mechanic which work and an ability that the player can use. If I had more time to work on the game, maybe it would have been something better, but for what I have now, I am really happy with what I have. 

Week 11 - Workshop Assignment GAM111.3

For this week and the week after this, I will be writing about my assignment primarily. 

From the previous week, I set a milestone saying that I'll try and put effects that would make my game fun and better to play. With this being said, I managed to get an idea for a power move, and something for the enemies when they get hit/die. I'll cover both of them in detail.

POWER MOVE:
For the power move, I was on my way home when I was thinking of a power move idea. It took me a while to get a few ideas, but the ones that were doable and made the game fun, was a power ability where the player were to shoot a ball, killing anything in its path, or towers having a faster fire rate towards enemies. I thought about the two, and weighed out the pros and cons. I chose the first one, as it would be fun to do, and the shooting mechanic for the player is complete, and bug free, whereas the other power move, I would need the turret mechanic to work in order for me to work on this power ability. 
The power move is inspired by the game OverWatch, from the hero Hanzo. His ultimate ability is to shoot an arrow, which then transforms into a dragon, doing immense damage to whoever is in its path. The path is straight, but if used correctly, it will turn the tide of the game. From this idea, I tried to implement the ultimate bar within the game (which increases over time and whenever you damage the enemy), and the ultimate ability itself. 

RESULTS:
After spending a few days to work on the power ability, experimenting with new things as well on the side, I managed to create an ability for the player. I added a power bar above the player within the scene. The power bar will increase over time (about 30 - 45 seconds) ONLY. I tried following the OverWatch mechanic, where it adds up over time, and/or when the player hits an enemy, but it would make the game unbalanced, and allowing the player to get the power ability every 10 seconds. Overall, I feel like the game is coming along nicely. The level is made properly, in the sense that everything is aligned, and all the shapes and sizes are similar and it all looks pleasing to the eye. The mechanics of what I have so far have made the game seem like a game, and it adds a difficulty curve, which is an added bonus for me. 

MILESTONE: 
For next week, I would like to add one more mechanic or effect that would round up the game, and ultimately, to get the turrets to work, which is my final basic requirement needed. 

Week 10 - Finite State Machine (FSM) GAM111

LECTURE:
What are Finite State Machines? A finite state machine is a system in which most companies would use for a basic AI system. It can also be used to keep track of what state a game is on, and even more! But during this lecture, we learning on how we can use an FSM as an AI in any project.

The concept of an FSM is to have a finite number of states, with a set of transitions between them. So if we were to make an enemy, we would give the enemy about 3 to 4 states. An idle state, patrolling state, attacking state, and a chasing state. Each state would have a specific logic written for them. So, to make a variable containing all these states, we write something like this:

Enum enemyState state {Attacking, Idle, Patrolling, Chasing};

Enums or enumerators(ions) allows you to create a collection of related constants. In this case, we are creating a collection of states for the enemy AI. Alongside this variable, we also need to make a current state, where it would set the default state, so something like:
curState = enemyState.Patrolling;

An FSM is sometimes followed by a switch case statement. This is where the transitions between each state happens. So if the player was in a certain range to the enemy, the enemy will then change to a state called Chasing (this is not how you would write it, this is for example sake only):
if (the distance of the player is > 40m) #This is where the logic will be written
{
    curState = enemyState.Chasing # This is where the transition between states would be
}
And if the player is closer to the enemy, the enemy would start to attack. So we would write the logic of the attack, and change curState to enemyState.Attacking, and so on, and so on.

SETBACKS:
I am still having troubles with the turret logic in the game, and it seems as though that I am at a stalemate with the turrets. I'm not gaining anything, neither am I losing anything. I keep on finding myself at the same spot.

ACHIEVEMENTS:
For this weeks achievements, I have:
I managed to get 3 enemies with different attributes. One small enemy (weak but fast), medium enemy (decent speed, decent health) and a big enemy (slow but deadly and "tank-y")
I managed to get a healthbar, for the base, and the enemies. Before this, the one type of enemy I got was a one-shot-one-kill enemy
I managed to get a basic UI system where it notifies the player when an enemy will spawn in

MILESTONES:
My milestones for next week are:
To finally get the turrets to work
To critically analyse if there is anything else I can add to make the game better
To find some assets in the store to make the game look better, other than using bland texts and/or blocks







Week 9 - Raycasting GAM111

LECTURE:
During today's lecture, we touched a topic about raycasting. I found the topic to be very interesting as it made me understand how somethings, within the games industry, were made. Examples include how crosshairs would change color when you aim at an enemy, how most RTSs (Real Time Strategy Games such as World of Warcraft or the Wargame series) can understand and detect how a player has selected a unit or a group of units to move into a spot. The answer is by using raycasts.

During this lecture, we didn't fully cover raycasts, but we went over on how they work and the logic behind it. A ray consist of a World Space origin, and a direction. It might sound simple, but how do we get the position of a mouse in world space? Well, we have to convert them, like how you would convert fractions when you want to add them together (not really like adding fractions together)

You have 4 different types of spaces:
Object Space - where models are stored in relative to the local point (0,0,0), in most cases, this would be the model's feet
World Space - where your objects are, in relative to the world space origin (0,0,0)
View space
Projection Space - applies either a "Perspective" or "Orthographic" projection to flatten a 3D position onto a 2D screen

The difference between the first two spaces and view space is that the view matrix doesn't transform the cameras position or rotation, however, it moves and rotates the scene by the opposite of the camera, somewhat similar to reciprocation. If you were to move the x axis by 10, the view matrix will move (-10, 0, 0).

To get raycasts to work, you need to get one single projection, which is called the World View Projection. In order to get this WVP, we need to multiply 3 matrices together. If we were to multiply two matrices together, we preserve both transforms.
(WVP = World Matrix * View Matrix * Projection Matrix)

The last part might seem a bit too advances (as warned by the lecturer), but all we need to know after the lecture was how raycasts work, or rather, the logic on how they work. The problem with raycasts is that you would lose some data about the model you're clicking at, as you're essentially turning that 3D object, into a 2D object onto the screen ultimately losing the Z axis information.

SETBACKS:
From the milestone I set myself for last week, I have encountered quite a few setbacks concerning the turrets. I tried making a turret, where it would look at the enemy entering its range, and shooting at it as it passes by. I underestimated this and found that I haven't got my turrets to work. It wouldn't look at the enemies as it passed by the turret, and it wouldn't shoot at the enemy, instead, it would shoot up at the sky. I tried taking a look at some tutorials online, but most of them included mathematical functions which I'm not familiar to, in coding terms to be precise.

ACHIEVEMENTS:
In every grey cloud, there is always a silver lining somewhere. The silver lining for this week is that I have managed to get a map, the enemy waypoint system to work, one type of enemy, and a player! Currently, I have managed to get the enemies to move along a waypoint system throughout their path, and a player object where you can shoot and build turrets with.

MILESTONES:
The milestone for next week are:
To find someway to implement a raycasting system into the game, where the player would click on a node and a turret would be built wherever the player clicked
To fix the turrets
To add some more enemies and some effects into the game
To make the game more challenging and fun to play

Week 8 - Assignment GAM111.3 Brief

LECTURE:
For this week, we were briefed on what our next assignment would be. For our third assignment of the module, we were tasked in making a tower defense game, something similar to South Park's Lets Go Tower Defense Play!
In case some of you aren't aware of what the concept of tower defenses are, you play as a character, who's tasked with stopping enemies reaching an end point. To lose the game, x amount of enemies will have to pass through the end point, or in some cases, the end point has a health bar which decreases, depending on what type of enemy passes through. The player can build defenses, such as turrets or towers to slow the enemies down or shoot them, or the player (in the South Park version) can shoot at them as well. Both outcomes will grant the player some coins to build some more, or to upgrade their tower.

REQUIREMENTS:
The base requirements of this assignment are:
Menu system - which includes a main menu, the game scene, a pause scene and a game over sceen
Win/Lose condition
Periodically produce energy (currency, bonus, points)
Minimum of 2 types of enemies
The enemies will follow a path through the level, causing destruction. The base health will be affected if an enemy passes through the end point

The bonus requirements of this assignment are:
Different types of towers
Additional enemies, upon the 2 that are required
Special abilities - carpet bombs and such
Enemies approaching in waves
More than one character can be played with
Having different routes, other than only having 1 route for the enemies to follow

MILESTONE:
The assignment seems like it requires quite a lot, doesn't it? But that is what we don't want, for us to be demotivated by the requirements of the assignment. At first, I thought that it would take some time to get the basic requirements set, but then I remembered that we covered some of the basics from previous lectures, such as waypoints, a menu system, a currency system and even spawning enemies, alongside with making different types of enemies. With this being said, for my milestone for the week, I will be setting myself a task to try and get the basic requirements done between this week, and Week 10 at the latest. Accomplishing this will allow me to get assets from the store and put them into the game to make it look nice and fun, and it would allow me to add in some effects which I practiced with into the game as well.

Week 7 - More work on Trail and Line Renderer GAM111

LECTURE:
Line and trail renderer might seem a bit simple in its primitive form, however it can be turned into something more and make a game more "juicier". The term "juicy" was taken from a video we watched during class on how to make your game better, no matter how simple it was. Watching this video, gave me inspiration for my next assignment, which was due in for Week 12. The video featured a simple game where you would control a small platform, and you would control a ball to hit blocks above. At first, the game looked very plain, no colors, no sound effects. But they started to add in simple effects which can be implemented, such as audio, trails for the ball, assets (or in the video, a face to the platform which would give the platform a sense of character) and such. Not only did this video give me inspiration, but it also showed me how something so simple might look like a great and fun game if you were to put in some effects that would make your game so much fun!

MILESTONES:
For the milestone of the week, I want to set a task for myself: to correctly use and understand how trail renderers and line renderers, so that I would be able to use them on my next assignment. Not only that, but before watching this video, I wasn't quite sure on how to add in assets from the assets store, and that bothered me a little, so I'll also take this chance to get familiar on how to use the assets as well.  

Tuesday, August 1, 2017

Week 5 & 6 - Reflection GAM111

(This week's blog will be more of a reflection and an evaluation of the past few weeks and the upcoming week.)
For this week, I'll do a different blog entry, since this week was a workshop session, where we had time to work on our assignment. A major setback for the past few weeks were the work load from different modules within the course. The different modules within the course held me back from doing practices which would help me in the assignment, and doing the assignment itself. With this setback, I have found myself far behind from my original deadline of finishing it early, but I fear that I will find myself struggling to finish the project with a good mark.

The session today allowed me to get some of my work done for the project, but the work done and completed during that time was not enough. With the lack of practice, I found myself stuck and forgot on how to use line rednerers, trail renderers and mix up the obstacles for the game. I have also forgotten to take in consideration of the fact that these obstacles will have to be spawned at the different Y axis of the game scene. After assessing my situation, I found myself rushing to put in all these details, and this goes without saying that rushing work is never a good solution. With this being said, I have found many errors within my code, and ultimately, I have made a bad project and didn't achieve my milestone for the project.

From this evaluation, balancing different module's work load is essential as it will save time for project clean-up, would open up time for breaks after a beta milestone is finished and it would avoid me from rushing my work within the last 2 weeks of the submission due date. From this massive setback (and a mistake, if you will), I have learnt my lesson, and I learnt it the hard way. For my next assignment, I shall put in more commitment, dedication and balance to all modules. 

Week 4 - Obstacles and Saving files GAM111

LECTURE:
During this week's lecture, we learnt how to make different obstacles, other than the generic boxes. We learnt how to make lasers, rockets and trails for our character and rocket. To make a laser grid or obstacle, we can use something called a Line Renderer component. What this does is it takes two points and creates a line. This can be done for a laser or for a rope. To turn this line into a LINE OF DEATH, we can either use a trigger or a OnCollisionEnter function to kill the player if they were to touch or collide into this line. A trail renderer is what the name entails, it renders a trail behind the desired game object. This is really useful if you want to use it if you were shooting a laser, throwing a grenade to see the trail of smoke it leaves behind and many other things. The picture below will present how a line renderer component looks like:

This part of the line rednerer component, but I find this part to be the one of interest for my project. The component asks us for the size, material and time of the trail. For the material, you can either change the color, add a texture or do both, add a texture and change the color of the texture. The graph below shows the dissipation of the trail. The higher the keypoint (the diamond shape points on the line), the thicker the line. So on this graph, I have made the trail so that after a certain amount of time, the trail will get smaller.


MILESTONES & ACHIEVEMENTS:
As always, this week's achievement was learning something new and making the project or any future projects better and appealing to the eye, or what one would call it, "juicy". I plan on putting in something extra for the obstacles, other than the generic box and coins to make the obstacles more immersive, and in doing so, I would need to make an array of game objects for the "spawner" to spawn these objects.


Week 3 - Making a HUD/UI - GAM111

LECTURE:
During this week's lecture, we learnt on how to make a UI - User Interface - or a HUD - Heads-Up Display - for our game. This is useful for our project as it will allow me to keep track on how far the player has gone, in terms of distance, and how many coins the player has attained on their run in the game. With the newfound knowledge of adding in a UI system, I can also add in a pause screen, game over screen and even a main menu screen (all of which are requirements of the project).
We covered some of the objects used under the UI tab in Unity, which were relevant to the project. We covered how to use texts, buttons, images and sliders. Our lecturer went through each one and taught us on how we can manipulate these game objects to do other things. For example, we can use a slider to represent a health bar, a timer and many more.

Code to represent a time bar
The image above shows a code on how I made a time bar during our workshop class this week. First, we had to find the slider within the inspector so we can manipulate the value of the time bar. I also made 2 variables for the damage and the time difference or the time interval. In the void Update() function, it simply means:
If the current time of the game is greater than or equal to the time interval, the slider value (100) will take damage(value), and this will go on every timeDiff(value).

MILESTONE & ACHIEVEMENTS:
An achievement for this week was the fact that I had learned something new in Unity which I can add for the project. Going back on the Jetpack Joyride assignment (if you don't remember, check previous blog post), I can use images to alert the player that they are being targeted by a missile, I can use texts as a means of a tutorial in the beginning of the game to help people who don't know about the game. During our workshop class today, I have managed to get a better understanding on how to implement these features within the project, all that is needed to be done is to put this in my everyday practice.
My milestone for next week is to further improve on my assignment.


Week 2 - Tips for Assignment 1 - GAM111

LECTURE:
On our second week of the course, our lecturer went through tips and tricks we could use for our game. We went through script functions - Awake(), FixedUpdate(), Start(), etc. - and explained to us what each function did and when they would be best to be implemented or used.
void Awake() and void Start()
In the image above, void Start() and private void Awake() can be seen. The Awake() function would initialize as soon as the game scene has been executed, whereas void Start() would start when the game object have been spawned into the scene. In this example, I have used a SetActive - another keyword/function we learnt - for a pause function in a project.

Along with scripting functions, our lecturer also covered velocity and a more realistic control or mechanic for the actual jetpack with a function called Rb.AddForce. To access the function .AddForce, first we need to access the game object's rigidbody component, and that can be done by the function [Name of variable here] = GetComponent<Rigidbody>() or a public Rigidbody [Name of variable] here.

Code for the jetpack controls
The image above is an example that I made after following the lecturer. Here, I have made a variable of the rigidbody component, and called it player. By having this component, I can then proceed to add in the force for the jetpack. public int up was used with Time.deltaTime - change in time - for the acceleration. This allowed the game object (or in this case the player) to jump up and down as if there were a jetpack attached to it.

MILESTONES & ACHIEVEMENTS:
From last week, I managed to put in whatever we went through on our last lecture, into simple practices with small pieces of code and other modules which require codes, such as GAM112. I found that this module helps out a lot with other modules as I learn new things and functions that can be used to add on more mechanics on future projects. For this week's milestone, and possibly the few weeks after the next, I would be working on the first assignment, allowing me to evaluate my work faster and learn where I went wrong. 

Week 1 - Introduction to GAM111

On our first week of this module, we went through some of the keywords and functions we have learnt during MDU112 last trimester. For our first lesson in 1 month, without looking back through old pieces of code, this lesson proved very useful for me, as it refreshed my memory on what each function or keyword would do. We went through things like:

OnCollisionEnter (Collision colinfo) - The function for any collision effects, such as bullets
OnCollisionEnter code




Time.timeScale/deltaTime/time - All Time functions, such as timer, time intervals, etc

Time.timeScale function used to pause the game within the Game Manager script


Components - We went through what a component is, allowing our lecturer to see our understanding of Unity
Viewing components within the Inspector in Unity3D
And many more were covered.

Other than going through keywords and functions, we also went through our assignments for this module. The first assignment was to make a JetPack Joyride-like game, with obstacles, lasers and such. Our second was to make a strategy game (which will be covered on a later post) and our final assignment was to make a blog throughout the week, writing down our milestones for the week and the upcoming week, how we overcame any obstacles or difficulties and more. Speaking of milestones, for the first few weeks, up to week 3, I aim to complete the weekly blogs, and by week 3, I aim to start working on the JetPack Joyride-like game.