I’m trying to create a AI for my 3d game, however after my AI dead i want it to disappear but i don’t know how to do it. I’m using Destroy method but i don’t know why it not disappear at all, so plz help
this is my code that I got so far
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public class detectHit : MonoBehaviour {
public Slider healthbar;
Animator anim;
void OnTriggerEnter(Collider other)
{
healthbar.value -= 20;
if (healthbar.value <= 0)
anim.SetBool ("isDead", true);
}
// Use this for initialization
void Start () {
anim = GetComponent<Animator> ();
}
// Update is called once per frame
void Update () {
if ("isDead" = true)
{
Destroy(gameObject, 5);
}
}
}