Thursday, 28 August 2014

The End? (week #12)

This week I finished my turn based strategy game by adding movement, the ability to attack and enemy AI. unfortunately the game did not turn out to be grid based like I hoped as I lack the programming skills in order to make that possible at the moment. The game acts like a turn based strategy game but the grid based movement and attacks are not precise.
the gameplay works by the player selecting a unit by using the left mousebutton which instantiates a green selection ring around the selected unit. the player then mouses over a series of cubes with the mesh renderer turned off, turning them back on to signal where the selected unit will move.
 if the right mouse button is pressed the unit will move to the cube and play it's walk animation. When the unit arives at its position the attack phase begins and a series of 4 cubes is instantiated around its position, if the player right clicks one of these cubes the unit will attack and play its attack animation, this will then lead to the enemy's turn.

If there are any good tutorials  on scripting a turn-based strategy game in C# using unity3D or someone could set me in the right direction please let me know as I would like to learn how to fix some of the problems I encountered. Thank you for reading

GUI and Floating Healthbars (week #11)

during this week I mainly worked on the GUI aspect of my turn based strategy game, for example floating  Health Bars for my units, backgrounds for the health bar,  text for when an attack misses and an icon for the poison status when a unit becomes poisoned. this is all handled by setting the screen position to MainCamera.WorldToScreenPoint and the position of the transform holding the script. a new rect is created at the screen position and tweaked in order to fit the right position for example this is the rectangle for my Health Bar:
Rect rect = new Rect (ScreenPos.x - 50, ScreenPos.y - 30, 100 / (100 / PlayerHealth), 15);
therectangle is also affected by the player's Health which causes it to reduced size the lower the players health becomes. A GUI.Box is created using the information shown in the rectangle but using its own GUIStyle variable allowing textures to be easily added to the health bar script.
I discovered how to created these floating GUI textures from this answer in Unity answers which I recommend you have a look at if you want to add a floating health bar to your game:
I also recommend reading the Unity Scripting API for camera.ScreenToWorldPoint which is linked here:

If you have any feedback about this post please let me know

Unit Selection (week #10)

for the selection of characters in my turn based strategy game I have used a raycast utilizing camera.ScreenPointToRay to the mouse position when the left mouse button is pressed. this ray then accesses the gameobjects that are carrying the player script allowing the public function "Selected."
On the player script there are numerous variables which are attatched but only a few are effected by the selected function, these include the public boolean selected which will be utilized to perform actions when the object's selected status is true or false and amountSelected integer which will be used to cap the amount of selected units.
when the selected function has been activated the script will then check the status of the selected and amountSelected variables, if selected is false and the amountSelected equals 0 then the selected variable becomes true and the amountselected equals 1 to prevent any more units from being selected at that time. This also instantiates a green ring similar to some real time strategy games like Starcraft and Warcraft at the position of the selected unit to provide some visual feedback letting the player know that the object has been selected.
if you are working on a project and you need some way of interacting with the world using your mouse cursor position I recommend looking at camera.ScreenPointToRay in the Unity Scripting API linked here :

Next week I plan on adding Health bars on top of units' heads which follow their position. if you have any feedback please let me know.

Final Project (week #9)

For my next project I am creating a turn based strategy game similar to games like Advance Wars, Fire Emblem and Final Fantasy Tactics but much more simplified. I plan on creating 3 Unit types, a basic melee unit  with low attack and high accuracy, a warlock type unit which inflicts poison to enemies with low accuracy and a large enemy that deals high area of effect damage with medium accuracy.

I haven't started scripting yet but i plan on using raycasts from the mouse position to perform actions like selection, movement and attacking.  I am not experienced at all with this genre so if you have any tips on how to make a turn based strategy game in Unity3D, please let me know

Shooting and Highscore (week #8)

This week was definately the most intense week I've faced during my studies as the pressure was building to finish my first person shooter. The 2 main things I added to my game were Raycast Shooting and a High score. At first I found it extremely difficult to understand Raycast Shooting as it is very different from anything I have encountered  during my studies but now it is quite simple.
I set it up by making an if statement to say when the left mouse button is clicked create a ray from the main camera transform position in a forward direction, if the ray hits a gameobject it instantiates a debris Prefab at the hitpoint. if the ray hits an object collider carrying the enemy script it accesses the recieve damage function from the enemy script.
In order to add a high score to my game I had to use System.IO to save and read .txt files. if the scorecount from my scorecontroller file is greater than the value saved on my score.txt file it becomes the new value for the score.txt file. The high score value is always displayed in a GUI.box by writing score.txt to a string as a high score variable.

My tutor Mike assisted me with all my work this week so unfortunately I am unable to provide any links to good tutorials but it is worth checking out the physics.raycast section of the Unity Scripting Api linked here : http://docs.unity3d.com/ScriptReference/Physics.Raycast.html

Health and Score (week #7)

Learning how to add Health and a Score was definately a new experience for me as I did not really know that scripts could access variables from other scripts which blew my mind at first. The Health Bar tutorial by BurgZerg Arcade was extremely helpful with understanding how to create a basic healthbar using GUI.Box and how to make the healthbar accessible by other scripts by using public static variables. here is the link to the tutorial series if you want to check it out.
Adding score to the game was very similar to adding health. this was done by adding a score controller into the game and using public static variables that were accessed by the enemy script when it was destroyed by my grenade prefab. The value of the score was placed in a GUI.box with the text "Score: " attatched. A tutorial which helped me with understanding the score is UnityChat's Coin Collecting tutorial which uses coins instead of score but it is basically the same premise. here is the link to the tutorial

Next week I expect to have fully completed my first person shooter game by adding Raycast Shooting and further developing the score in my game by adding a Highscore.

Animation (week #6)

This week I put a lot of work into animation and making my enemy game objects perform different actions at certain distances. The animation was fairly simple to pick up and use as I was using prebuilt prefabs I gathered from the assets store in Unity3D already built with an animation controller and animations.
The animations were performed using the Animation.Play() and Animation.Stop() functions using several if statements to determine when these functions should apply. Here is a link to the Unity Scripting API if anyone is interested
In order to determine the distance from the player to the enemy, I created a float using Vector3.Distance and using if statements which check if the value of the distance is greater than a certain number or below it. once again here is the link to the Unity Scripting API for Vector3.Distance

Next week I expect to learn more about health and scoring in my game and I will let you know my findings.

First Person (week #5)

For our new project we are required to create a 3 Dimensional game which utilizes a 1st person or 3rd person camera. At the moment I am learning how to create a first person controller in order to understand how it works and so I can use it in the future games without the need to use only the standard character controller that unity provides, allowing more freedom with the scripting of it.
 The tutorial by quill18creates really helped me out through this process as he goes into great depth about the basic aspects of creating a first person shooter in unity. I think it is definitely worth checking out if you are new to scripting or creating first person shooters in Unity3D and here is a link to the tutorial https://www.youtube.com/watch?v=rhpJPx8fICQ .

next week I plan on discovering more about basics of  first person shooters as the genre is so popular at the moment and will definitely be beneficial to learn about for my game development career.

Tuesday, 8 July 2014

The Build (week #4)

This week was definitely one of the most intense that I have experienced at this college in any subject due to the sheer amount of work I had to do to comply with the assessment brief. Although I did not have everything that the brief asked for such as a score system I was very proud about how it turned out. I created a prototype for a 2D top-down shooter with 2 types of enemies, a zombie which runs towards the player and a turret which does not move but constantly rotates towards the player and fires bullets at them. The player has 2 ways of destroying them, a basic gun shot with a fairly short cooldown and a grenade which explodes on contact with an enemy or after a short amount of time, inflicting an area of effect explosion which has a long cooldown period. The aim of the game was to survive as long as possible from the enemies with a high score board for who survived for the longest, unfortunately I did not have enough time to implement this into it. Although the prototype was not a fully-fledged game, it definitely set the foundation for some of my future work and perhaps this concept may be built upon. I was definitely happy with the work I had created especially due to the fact that I had no programming skills at the start of this year. 

A Game Designer’s struggle (Week #3)

In our tutorial this week we were asked to create an object that spawns faster as time goes on. I struggled with this quite a bit as I couldn’t find out how to do this using the unity scripting reference. I am new to programming and I didn’t believe that I should look at tutorials or ask my lecturer about this until I was completely unsure. I was too hard headed to ask how to go about doing this so I left myself quite disadvantaged while other students seemed to be moving along quite adequately. The tutorial this week was completely unproductive for me as I spent 2 hours trying to do one very simple task which in the end didn’t work out. This has taught me that I should ask questions as soon as a problem comes across in scripting. Later in my own time I discovered that the answer to scripting this was very simple and could be solved using simple mathematics and variables which subtract from the spawn time every time an enemy is spawned and forcing the minimum spawn time to stay at 1 second so that the game does not become too overwhelming or lag from the amount of objects in the scene.

Basic Enemy Script (week #2)

This week we were asked to design an enemy with 3 behaviours; enter, shoot and escape. Due to being ill I was not able to participate in this task in class but I was able to create an enemy AI suitable to the brief for our first assignment. For this assignment we are asked to create a 2D video game in Unity which must apply to a brief, this brief contains many points that our game should contain, the main ones being Dynamic Object spawning, level extents, escalating difficulty and audio. Through research I learned how to create a follow script for an enemy so that it is constantly rotating toward the player and moving in that direction. This script was also edited for a turret style enemy which does not move but rotates toward the player and instantiates bullets over a set time using a cooldown. With these I aim to create a simple top down shooter which features waves of enemies which spawn faster the longer the player survives.

Thursday, 5 June 2014

An Introduction

Hi, My name is Peter and I have created this blog as an assessment task for a subject I am currently studying called Scripting for Game Developers as part of my Bachelor of Game Development. As the title of the subject I am currently studying suggests, I am learning to script code for video games which I believe will be extremely beneficial for myself due to my current lack of scripting knowledge and hopefully beneficial for the industry as I hope to erase some of the negative attitude conveyed toward it through the creation of my video games. This blog will outline my progression as a game developer, explain my scripting goals and hopefully acquire feedback and perhaps exchange information with other individuals in the industry. For this week's tutorial we learned some basic movement and camera scripts for a 3rd Person video game which I wish to improve upon by adapting those scripts to different genres such as 2D Platformers and first person shooters. I would like to achieve these goals so that I will be able to open myself to different possibilities and create enjoyable prototypes for different genres that may eventually become fully fledged video games. Learning the movement and camera scripts for different genres will assist in creating the most important part of a video game: the controls which will set the base for my wild imagination to build upon and also slightly improve my value as a  team member in the industry. Thank you for reading and please leave a comment on any thoughts you may have.