Wednesday, 5 June 2013

Adding Health to the Character, Respawning and Healthups

Health was added to the Main Character with creating a Health variable that change when it interacted with a script that dealth "damage". Basically, damage is the decreasing of the value assigned to the Health variable, as the health goes lower the GUI image for Health changes. Overall I have 11 images for health, when the Health variable is at 100, the healthbar looks full, when it is at 0 it is empty.
Additionally I managed to set the script that when the player ran out of health the script would send a message that would activate a function within my main player controller script that would cause it to respawn at the character respawn point with all it's health. Effectively, if the player were to run out of health or fall out of the game they would have all their health returned to them and be brought back to the spawn point. To the right is an image of the Health at 50% when the character has taken some damage from an object with the damage script. (Bare in mind this is not the final resolution for the game).

Furthermore I've managed to create a script that would add a value to the health when the character would interact with it. The object itself acts as a type of Health pickup and is destroyed when the main player touches it. Similarly the same method is used with the checkpoint as I have both object rotating in mid-air, they both get destroyed on contact but do different functions.
Below is the code for the Health-up script.
function OnTriggerEnter (other : Collider) {
    other.gameObject.SendMessage ("hup30", SendMessageOptions.DontRequireReceiver);
    Destroy (gameObject);
}

function hup30 ()
{
HEALTH = HEALTH + 30;
}

And below this text is the code for the checkpoint script.

var spawnPoint : Transform;

function OnTriggerEnter (other : Collider) {
 if(other.tag == "Player") {
 spawnPoint.position = Vector3(75, 10, 0);
 Destroy(gameObject);
 }

}

Sunday, 2 June 2013

Placing down Platforms, Character Creation and Setting up the Camera

Now, in order for the character to move around the scene we need some physical colliders they can jump to and from, in other words we need some platforms! By placing a few rectangle shape gameobjects into the scene-view I will effectively be creating platforms, what I must make sure though is that they're located along the same Z-axis as one another otherwise they won't be inline. The reasoning to why these default gameobjects will act as platforms is due to their individual box colliders. These box colliders give solid-like properties to these objects when placed within the scene. If these objects didn't have the box colliders then the characters/dynamic shapes would just fall through the platforms and outside the level.
Additionally, the platforms that are touching eachother are put into the same empty parent object which has a "Combine Children" script. This script takes all of the children objects (platforms) and combines all their meshes together. Therefore instead of rendering 6 different objects, only 1 object is rendered saving memory and enhancing game performance.

So far in our game we have the attributes of the level set and a few test-platforms to inhabit it however we're missing our main character! Introducing the prototype character that will be controlled by the user, "Capsule". Capsule isn't like any other default gameobject in Unity, through a little bit of tinkering I've managed to give it the basic movement controls it needs to explore the scene. This is done through the Platform Controller script I attached to it. What this specifically does is that it works alongside with the inbuilt CharacterController component Unity has and defines the physical mechanics within the environment. Additionally, through the Inspector pane on Unity I can optimize the variety of functions the Platform Controller Script inhabits, for example I can change the walk or run speed of the character or jump height, etc.

Even though we now have a simple character moving around an environment we need to introduce the Main Camera otherwise they will just walk offscreen! We need the Main Camera to do the following:
  • We need the camera to follow the character but to also introduce the subtle movement when the character moves further in one direction. The camera in this game is much like the style of games such as Defender, this allows the player to easily view what is ahead of the level before they reach it.
     
  • We also need the camera to track the main character when it jumps by adding a "springiness" property to the camera script. To make it not so jumpy for the player, it is preferred for the camera to not follow the complete motion for when the character jumps. By making the camera lag with the springiness property, we can stop it following the complete jumping motion

In order to achieve these objectives we can add the following scripts to the camera object.
Camera Scrolling: Allows the camera to move how we want with a distance property and a springiness property. The distance property (z-direction), sets the distance away from the target object (our main character).
Springiness Property: Stops the camera from following the complete jumping motion. The value itself defines how responsive the camera is to the target motion.

As well as the basic camera features we also have a few camera features set to our character, this script is called "CameraTargetAttributes".

Height offset: If set to 0, target will be sitting vertically center of the screen. If set to positive number, the camera will shift upwards which would create a vertically off-centre target.
Distance Modifier: We can modify the distance of the camera from the target, this setting adds onto the value that is defined in the camerascrolling script. (This functionality is good for multiple targets).
Vertically look ahead: Defines how quickly the camera shifts to look ahead when the target is moving.
Max look ahead: In order for the character not to leave the screen the value set here is the distance that the camera will stop looking ahead. X is horozontal distance whilst Y is vertical distance.

Setting the Game Attributes

With the creation of my title pages I am now going to start the game development process for my Final Major Project. My first goal with this level is to create an environment that I can walk around and have a few platforms to jump from one to the other.
When creating a game in Unity that is predominantly 2D we need to understand the common principles that will stay consistent in order for the project to function. To start off we need to define our plane of motion for all of the gameobjects. In order to prevent this game from being three dimensional, one of the dimensions must be restricted from motion. For my game, I’m going to choose the X-axis to correspond to horizontal movement and the Y-axis to correspond to vertical movement. The Z-axis will therefore correspond to movement to and from the observer (or camera), this will inhabit no character movement within it. In order to easily memorize the planes of motion, when I click upon a Gameobject within the Scene-view, the red, green and blue arrows represent the directions of X, Y and Z.
The second principle I'm going to be sticking to is the restriction of rotation. The only rotation that will be present within the game will be around the z-axis. This is due to the camera passing through this axis, which results in clockwise and anti-clockwise rotation. The only exception that will be used for this rotation is the Y-axis so he can turn from side to side in mid-air.

In order to help enforce these principles I'm going to use an object called "Level Attributes" that has a script with the same name attached to it. This script does a whole variety of environment setting features, these features do the following:
  • Displays the level's dimensions within the scene-view by drawing a green bordered rectangle.
  • Creates a physical collider that acts as a border to stop objects falling infinitely or users going beyond where they should be going.
  • Allows the user to optimize the position where the physical colliders start and how wide/high they are away from the position.
  • Gives the character room to fall without the camera following it until it hits the bottom collide.
So now we have a script that creates an area for the character to move up and down the X and Y axis, however if the character were to fall to the boundry of this area nothing would happen. This is where we implement the Death Zone object that has the "DeathTrigger" script attached to it. What this script does is that it provides a collider which causes the character to respawn if they fall onto it, this is a great feature for small pits or the whole level itself.

Friday, 31 May 2013

Developing the Crosshair

From my initial Crosshair development I ended up deciding that I wanted to create a crosshair that was simple in it's design yet unique. Therefore when I was drawing up my various ideas I tried to keep my sketches geometric and easily interpeted by others. In the final stages of my drawing I highlighted a few designs that I preferred and was going to develop further in Photoshop. So when it got to working in Photoshop I did two designs that were heavily focussed around the simple shape of a circle.
The image to the right displays the 2 final outcomes I ended up with, one with 4 crescent moons focussed around a circle and another with 4 banana-like shapes. I think for my final game I'm going to choose the crescent design as the 4 shapes resembles more of a hidden circle than the banana design does. Additionally I find that the crescent design is more coherent with conventional crosshairs found in all types of video games. For example, the image to the right displays the UI from Team Fortress 2, the game designers there decided to go for a more simple approach to their crosshair with a circle that has 4 spaced out segments removed, resembling an invisible X-shape through the circle.

Now in order to implement the design within Unity I needed to have a script that would hide the default windows mouse cursor and replace it with my design within the game. Additionally I needed the new design to act the same as the default cursor by following it around wherever the user would move their mouse to. Whilst trawling around on the interwebs I found a script that could be attached to the main camera (so it used the 2D GUI plane) and used a variable to display any design I wanted for my crosshair. The key issue though was that it was optimised for a set screen size but I personally wanted it to be more flexible around any size the game may find itself at. Therefore I changed the math.clamp for the position of the mouse to start at the top left of the gamespace and be the width/height of the current screen size. The image above shows the code that I used for the crosshair to be put within Unity.

Wednesday, 29 May 2013

Creating the Info Page

To help me create the design to the information page I'm going to use the layout I used for my 3D Sound Toy. Of course the information and content will be different but the explanation of the Interface elements and Controls will remain. Firstly though, I need to develop the Interface elements that will be shown ingame and on the info page, and also structure out what is going to be exactly shown on the page itself. The spaced out text below shows the skeleton of what I'm going to be displaying to the user on the info page.
Cure Logo
   Input Controls 
  • [IMG] Use W-A-S-D to move the Main Character around the Environment 
  • [IMG] Click the Left Mouse Button to fire an arrow in the direction of the crosshair
  • [IMG] Use the Space-Bar to jump around the environment
 In-Game Icons
  • [IMG] This displays how much health the Main character has left
  • [IMG] This is the Crosshair for aiming towards your target.







After much spacing out and resizing I have finished what I needed to explain on my information
page. As you can see by looking at the image to the right I have taken out the initially proposed "Ingame Icons" section. I did this because I felt that it's general video game etiquette to understand what a crosshair/health bar is. If somebody came across and didn't understand those icons with some trial and error they quickly would.
The other (minimised) image to the right is the code that I used for laying out the info page, the key differences to the previous info page I did for the 3D sound toy is the paragraph text I had to implement, the logo and the new exit button.

Sunday, 26 May 2013

Creating the Menu and Logo

With my previous experience with Unity from the Interactive Media Authoring Unit I've started to develop the Menu system for my game. If my evidence seems lacking explanation and detail, please refer to the development blog post with Unity here.

Because I have finished developing my logo on paper, I've decided to now use photoshop to refine the final outcome of the title and buttons for the menu screen. The process to doing this meant that I was going to take the assets I drew and go over them with the Pen tool.



The image to the right displays the elixir I drew up in my sketchbook and am now currently developing in Photoshop this moment. To help me develop the background logo icon I also looked towards the Health Elixir from the MMORPG Tera.








With thorough usage of the Pen Tool and Blending Options (e.g. Gradient Overlay), I've managed to create an elixir that will look perfect for the background of my logo.




By using a simple stroke I've managed to outline the font I have chosen for the type. For the smoke I used the first 4 steps of this tutorial. To sum up, I took a shape, blurred it and liquified it after.





Instead of using the GUI font styles Unity offered I decided to use images for my buttons as they are going to be subject to change. For the Menu layout I used a similar design as I used for my 3D sound toy however as I was going to be including a logo and new images I needed to space out my elements differently. In this case I decided to space out my elements differently around a photoshop region, this allowed me to have buttons that were not confined to a box like in my 3D Sound toy. Adittionally I also added on a hover affect that this time around did not change the colour however gave the image 2 stars either side and offset the image down by 10 pixels. By looking at the video to the top right you can see how I designed my menu differently to my 3D sound toy. This time around I found it quite hard to space out and get the sizings right as it wasn't dependant on the button box I had beforehand but the flexibility of the font style.









After a simple implementation of the logo with the aide of this Unity help webpage I have more or less completed a simple Menu for my 2.5D Game! To the right is an image of how the Final Menu looks and below that is the code that puts it together.



Saturday, 25 May 2013

Sketching out the Interface Elements

Over the past few weeks I have been sketching out various ideas for the specific interface elements to my game. With using the Mindmap I previously drew out as a guide, I have created a whole plethora of interface elements that I am going to be selecting and developing upon within Photoshop.

Crosshair Designs


















Menu Design
 
Hit Animation/Objective Hints/Health Bars