how i can put a animation first play animation then destroy
void OnTriggerEnter(Collider otherObject)
{
if(otherObject.name == "untitled")
{
Destroy(otherObject.gameObject);
}
if(otherObject.name == "Boss")
{
Destroy(otherObject.gameObject);
}
}
}
This is what I do. Animation is set in a var.
When Played and gets to 90% I destroy the object.
public var die: AnimationClip;
***Your Script do kill enemy etc..*
animation.Play (die.name);
if(animation[die.name].time>animation[die.name].length*0.9)
{
Destroy(gameObject);
}
void OnTriggerEnter(Collider otherObject)
{
if(otherObject.name == “untitled”)
{
StartCoroutine(animthendestroy());
}
IEnumerator animthendestroy()
{
animation.Play();
yield return new WaitForSeconds(here you enter the seconds it takes to play the anim();
Destroy(otherObject.gameObject);
}