Hello there
Can someone help me with this issue ?
My problem is that I can get the sound to work fine when the “Asteroid” Collides with the “Player” but as soon as the Asteroids collide with “Bolt” or “Asteroid”(When it Collides with other asteroids)
it want play any sound at all?
Thanks before hand!
#pragma strict
//Explotion Effects
var ExplotionEffect : GameObject;
var PlayerExplotion : GameObject;
//Values
var AsteroidValue = 1;
var LifeValue = 1;
//Player reset function
var PRB : Rigidbody2D;
//Pickups
var UPBolt : GameObject;
//Timer function
var ScreenWait : float;
var DieText : GameObject;
//Sounds
var AsteroidExplotionSound : AudioClip;
function OnTriggerEnter2D(other : Collider2D){
//Get Source
GetComponent.<AudioSource>().clip = AsteroidExplotionSound;
//Makes sure that "Asteroids" and "Boundary" ignores each others Collider2D
if(other.tag == "Boundary"){
//Returns the Collider2D value without Destroying it.
return;
}
if(other.tag == "Player"){
//Sound
GetComponent.<AudioSource>().Play();
//Instantiats "PlayerExplotion", when "Player" Collides with "Asteroid"
var PlayerExplotionEffect = Instantiate(PlayerExplotion, other.transform.position, other.transform.rotation);
Destroy(PlayerExplotionEffect, 0.90);
//Instantiates "ExplotionEffect" when "Asteroid" is destroyed
var AsteroidExplotionEffect = Instantiate(ExplotionEffect, transform.position, transform.rotation);
Destroy(AsteroidExplotionEffect, 0.90);
//When "player" is destroyd, waiting time and jumping to "GameOverScreen"
Destroy(other.gameObject);
//"Player" Loses a LifePoint
GameMaster.CurrentLifes -= LifeValue;
yield WaitForSeconds(ScreenWait);
Application.LoadLevel("GameOverScreen");
}
if(other.tag == "Bolt"){
//Sound
GetComponent.<AudioSource>().Play();
//Score Update
GameMaster.CurrentScore += AsteroidValue;
//Instantiates UPBolt PickUp
var PickUp = Instantiate(UPBolt, transform.position, transform.rotation);
Destroy(PickUp, 5);
//Instantiates "ExplotionEffect" when "Asteroid" is destroyed
var AsteroidExplotionEffect2 = Instantiate(ExplotionEffect, transform.position, transform.rotation);
Destroy(AsteroidExplotionEffect2, 0.90);
}
if(other.tag == "Asteroid"){
//Sound
GetComponent.<AudioSource>().Play();
//Instantiates "ExplotionEffect" when "Asteroid" is destroyed
var AsteroidExplotionEffect3 = Instantiate(ExplotionEffect, transform.position, transform.rotation);
Destroy(AsteroidExplotionEffect3, 0.90);
}
if(other.tag == "Wall"){
//Returns the Collider2D value without Destroying it.
return;
}
if(other.tag == "PickUps"){
//Returns the Collider2D value without Destroying it.
return;
}
//Destroys everything, which enters Collider2D and itself.
Destroy(other.gameObject);
Destroy(gameObject);
}