Hi i am trying to make an explosion effect when an enemy in my game dies. i am using raycast shooting and damage scripts to attack and kill the enemies.
I’ve made a code to check if the enemy is dead and then Instantiate a particle system to the enemies position, but when i kill the enemy he just pops away rather than exploding. i am fairly new to programming so forgive my somewhat sloppy code.
#pragma strict
var Health = 100;
var Effect : Transform;
function Update ()
{
if (Health <= 0)
{
Dead();}
}
function ApplyDamage (TheDamage : int)
{
Health -= TheDamage;
}
function Dead()
{
Destroy (gameObject);
}
if (Dead) {
var boom = Instantiate (Effect, transform.position, transform.rotation);
Destroy(boom.gameObject, 10);
}