Been at this for a while now and was wondering if anyone had a good idea as how to do it. I'm trying to destroy the enemy bot and when he dies, I want him to collapse to the ground and THEN explode. At the moment, the best i've been able to do is have him do his collapse animation and then explode upon one shot.
using UnityEngine;
using System.Collections;
public class SpiderEnemy : Entity
{
public float expOnDeath;
private PlayerLevel player;
public GameObject explosion;
public AudioClip blastSound;
private Animator animator;
private AnimatorStateInfo currentBaseState;
static int DestroyedState = Animator.StringToHash("Base Layer.Destroyed");
void Start()
{
animator = GetComponent();
player = GameObject.FindGameObjectWithTag("PlayerLevel").GetComponent();
}
void Update()
{
currentBaseState = animator.GetCurrentAnimatorStateInfo(0);
}
public override void Die()
{
animator.SetTrigger("Destroyed");
if(currentBaseState.nameHash == DestroyedState)
{
player.AddExperience(expOnDeath);
base.Die();
AudioSource.PlayClipAtPoint(blastSound, transform.position);
Instantiate (explosion,transform.position,transform.rotation);
}
}
}
↧