• Twitter
  • Facebook
  • Google+
  • RSS Feed
Showing posts with label Interactivity (Professional Toolkit). Show all posts
Showing posts with label Interactivity (Professional Toolkit). Show all posts

Friday, 20 March 2015

To further develop my game I have done numerous things. I have made my background move, created a start menu where you press 'Play' to begin the game and I have created a pause button which freezes the game by pressing the 'P' key and unfreezes after you press the key again.

I began with making my background scroll across, to look like the ship is moving in space. To do this, Luke showed me a simple piece of coding.

This 'ScrollSpeed' text allows for me to change the speed I want the background to go at in the game, for now set at '1' as shown under the void update. 'Vector2' for example simply means that the game is a 2-D game. The 'rendered.shared.Material.SetTextureOffset...' simply sets the positioning of the background, meaning it will move the background material in game.

I then moved onto making a simple menu for my game. To do this I needed to create a new scene and call it 'Play Game (Start Menu)
Unity file in game. 

I then had to create a new UI Button by going from GameObject > UI > Button. 
I then changed the settings for the button around the text and the text around the button by changing the colour and highlighted colour of the button and the colour of the text to something more suitable. I also downloaded a free space font from 'Dafont.com' to make my game more space themed.
 Settings for my button.
Setttings for my 'Text', with a custom font. 

I then created an empty object and called it 'Manager' to allow the scene to change from one to another. I then created a 'Change Scene' script to allow this to happen. This was found through a YouTube tutorial on how to make a menu for your game.

I then attached this script to the manager and the 'Canvas', which is the collection of my button and text.
'_Manager' in game. 

'Change Scene' Script. 

The script allows for it to use this scene and change it to the next. This is done by changing the build settings to allow the 'Play Game' scene to appear first, followed by my actual game. The 'Add Current' button adds my scene to the build so it will appear in the game when it runs. 
The 'Build Settings' for my game 

To make the scene change successfully, we have to add the manager to the left hand side, under 'Runtime Only' and add the 'Space Shooter' unity game to the 'ChangeScene.ChangeToScene' option in the drop down menu.
 The settings to 'On Click ()' 
Changing the option to 'ChangeToScene (string) to allow the actual game to appear after clicking the play game button.


I finally created a simple pause function. To do this I created a new script called 'PauseScreen' and attached it to my Player to pause the game.

This script allows for the 'P' key to pause everything within the game (Input.GetKeyDown(KeyCode.P). The 'Time.timeScale =...' means the time taken for the game to pause and un-pause.


Overall i'm really pleased with the development i've made to my game (Adding my own ship/asteroid/UFO, changing the background, making it move, adding a pause/start function, having multiple objects fall and changing the score value of each object). I feel I understand coding a lot better now thanks to Luke and I would feel quite more confident than I have prior to the lessons in producing my own game in the future. When starting the project I found it difficult because I've had no previous experience in game programming, however I feel I have progressed well and now understand the basics of making a game. If I would've had more time I would've made an enemy ship or perhaps made the game multiplayer to further develop my game, which I may look into working on after the unit has been completed.

Saturday, 14 March 2015

After we had finished the basics, I decided to  customise my game and add some further elements. I began by customising the background to my game. I found a star texture on the internet and changed the image by colour correcting it.

Customised background.

I then imported my own ship into my game and added all of the components and scripts to it. I further customised my own ship by adding a texture and colour correcting it. 

 Spaceship in game. 

 Custom ship texture in Photoshop. 

Texture added to my ship. 

I then changed my 'GameController' script to allow multiple items tumbling down my game. To do this, Luke showed me a simple piece of code that allows more than one hazard to occur. This means I can import my own models. 







I then imported my other models I made in Maya. These were my own Asteroid and my own UFO. I imported these into my game by exporting them in Maya as 'FBX' files, and then added the textures separately. I then took the settings from the asteroid such as the the scripts and capsule collider's and moved them onto my UFO and Asteroid. 

 Copied scripts from the Asteroid to my custom asteroid. 

Edited capsule colliders for my Asteroid and UFO.

Luke then showed me how to make my UFO spin instead of tumble, so he helped me create a new script hat allows for the axis on the UFO to spin instead. 

Script in game. 

Script created to allow the UFO to spin rather than tumble. 

Multiple objects in my game. 

I then decided to change the value of each object. For example, my custom asteroid is worth '20' points rather than 10 points you get from the normal asteroid's. I also made my asteroid tumble more and fall quicker than the regular asteroid's by changing the mover speed. I also made my UFO worth 50 points and made it move even quicker and spin instead of just rotate. 



I then decided to change the bolt colour to a different colour that I felt would suit my game better. 


Changed Bolt colour to green. 

I then decided to add another asteroid to my game and change the size of it. I used the same design as the original asteroid however I increased the speed, points value and tumble speed to make it more difficult to shoot. 

Smaller Asteroid prefab. 

Changed settings. 

 I then customised my UFO more by making the explosion sound effect different to the asteroid's. To do this, I used a different sound prefab. This was 'explosion_enemy' rather than 'explosion_asteroid'.


To develop my game further I plan on making a start menu and pause menu. 

Thursday, 12 March 2015

During today's lesson we were shown how to add sound effects such as asteroid and ship explosion sounds and pieces of text to our game i.e. score count and game over text.

We began by adding sound effects to our asteroid explosion and ship explosion.

 Adding a component to my explosion prefab under the 'Audio' section, selecting 'Audio Source'. 

 'explosion_player' sound effect added to our 'explosion_player' prefab. 

 'explosion_asteroid' sound effect added to our 'explosion_asteroid' prefab. 

'explosion_enemy' sound effect added to our 'explosion_enemy' prefab. 

I then started adding text to my game by importing 3 different texts by creating a new 'UI  > Text' 


Three created UI text's

We then edited our 'GameController' text to allow our text in game and for our 'ScoreText' to change as you hit the asteroid prefab. We also added a restart function using the 'RestartText' we created. The 'Void Start()....' allowed for the number to increase when you shoot an asteroid, along with the 'Public void AddScore'. The 'if (restart)...' function allowed for the 'R' key input to restart the game, with the if statement under it referencing to the text saying 'Press 'R' to Restart' (RestartText in our game). 


I then edited all my pieces of text by moving it to the correct position and setting the size, font, color and so on.


'Game Over' settings.

We then added more pieces of code to our 'DestroyByContact' script. The coding below allowed the score value to increase when you shoot the asteroid. The 'GameController' variable allows the functionality of the 'AddScore' variable. 



This was our last lesson with Luke and I feel confident using Unity now, and I plan to go off and customise my game further. 

Tuesday, 24 February 2015

During today's Interactivity workshop we looked at making the ship and asteroids explode when they collide. We also looked at making a script that allowed multiple asteroids to spawn when playing our game.We began with a simple piece of coding called 'DestroyByContact' allowing our asteroid to disappear when its hit. 

Coding to destroy the asteroid.

We then tagged our boundary under 'Boundary' so the  boundary is separate meaning it won't keep the bolt.

Tagging the boundary.
This piece of coding allows for the asteroid to be destroyed.
This line of coding allows for an explosion option within our game, where we can attach theexplosion preset. We then added the explosion effect to our asteroid. 

This line of code allows for the ship to explode when it hits the asteroid. 
We then selected the player explosion preset, which is a larger explosion than the asteroid's explosion.



The next section of code allows for the ship to have a much larger explosion when it hits an asteroid

 
Making the speed negative also allowed for the asteroid to come towards us.

We then made the asteroid a prefab so we can have multiple identical asteroid's in our game rather than having to keep making another asteroid from scratch,


The next task we did was to create a ‘GameController’ empty object on our hierarchy and tag it as 'gamecontroller'. The game controller will be used to spawn multiple asteroids at once.

'GameController' tag. 
Original GameController script.
We then added elements to our existing ‘GameController’ to change the speed of how quickly the asteroid's spawn and for the waves of asteroids appearing to constantly loop.


Settings for the wave of asteroids.

Next lesson we will work on finishing our game by customizing our game by importing our own ships and asteroid's we've made using Maya.
 
© 2012. Design by Main-Blogger - Blogger Template and Blogging Stuff