I’m making a 3d game with a bunch of asteroids flying around and the player controls a ship that can shoot the asteroids and i want to make it so when the lazer (a cylinder with a trail) hits it it dellets and the partical animation happens
this is what im trying to do now
void OnCollisionEnter(Collision col) //the script is on the asteroid
{
var a = currentAsteroid.localScale;
scaleOfAsteroid = a.x; //the asteroinds can be diffrent sizes
if (col.gameObject.name == gameObjectName)
{
//Destroy object it is colliding with
Destroy(col.gameObject); //destroying the lazer that hits it
//Destroys object it is attached to (asteroid)
//INSERT ROCK EXPLOSION INTO GAMEOBJECT
//Destroy(Instantiate(GameObject.Find("RockObject")).gameObject, 4);
//a script to make diffrent things happen if the asteroid is diffrent sizes
if (scaleOfAsteroid >= asteroidSizeToSpawnMore)
{
Invoke("Explode", 0f); //invoking the script to make the particals happen
Destroy(gameObject); //distroying the asteroid
}
else
{
Invoke("Explode", 0f); //invoking the script to make the particals happen
Destroy(gameObject); //distroying the asteroid
}
}
void Explode()
{
test = GameObject.Find("RockExplosion").GetComponent<ParticleSystem>();
//replacing the asteroind with the animation???
//testing things
//var test = GameObject.Find("RockObject").GetComponent<RockExplosion>();
test.Play(); //playing the animation????
}
}
any help would be great thank you