Sunday, May 1, 2011

Getting The Dynamite And Blasting The Rocks Clear



I added the Rocks Explosion animation into Unity 3D and added all the scripts. I was trying to make it work using animation events but there is something about imported animations that either does not allow you to use animation events or I'm missing something. So what I ended up doing was something simple like this in my FallenRocks.js

function Unblock() {
animation.Play("DynamitePlacement");
fallenRocksState = fallenRocksStates.unblocked;
audio.PlayOneShot (fallenRocksPlacementSound);
print("Dynamite Is Placed");

}
function Open(){
yield WaitForSeconds(5);
animation.Play("FallenRocksExplode");
fallenRocksState = fallenRocksStates.open;
yield WaitForSeconds(3.5);
Instantiate (fallenRocksExplosion, transform.position, transform.rotation);
print("Path Is Unblocked");



I had to run the game a few times to tweak the wait for seconds to get the explosion to match up but it worked. You have 5 seconds to get clear of the blast too otherwise that explosion will kill you dead if you are too close.
As you can see I did a little sightseeing on the way to the rocks blocking the path, killed a couple of "Alien Zombies" , checked out the "Chicken eating Zombie" , looked at some fireflies, figured I'd show you some of the sights in the game as I was on the way to blast the rocks clear.

No comments:

Post a Comment