• Twitter
  • Facebook
  • Google+
  • RSS Feed

Tuesday, 24 February 2015

Interactivity 6- Making the asteroid's and ship explode

No comments:
 
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.

No comments:

Post a Comment

 
© 2012. Design by Main-Blogger - Blogger Template and Blogging Stuff