If I put a little group of these AI it still good (Not distinguish) but if I put them to a huge armed force they are going to be as the video.
As you can see in the video. Now if I delete a Rregibody then the AI is going to work correctly. So I think the cause is this Rigibody I guess.
But I can’t fix it by just delete it because I still need it for some purposes.
The code that may connect with this RIgibody is this. (I need it stop woking after the AI get kill.)
row 54
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class detectHit : MonoBehaviour
{
public GameObject HP;
public Slider healthbar;
Animator anim;
public string opponent;
void Start()
{
anim = GetComponent<Animator>();
}
void OnTriggerEnter(Collider other)
{
{
if (other.gameObject.tag != opponent) return;
{
// if (Input.GetMouseButton(0)) ;
{
healthbar.value -= 30;
}
} }
{
if (healthbar.value <= 0)
anim.SetBool("isDead", true);
{
//if (healthbar.value <= 0)
// Destroy(GameObject.Find("AIhb"));
{
if (healthbar.value<=0)
Object.Destroy(GetComponent<Rigidbody>());
{
if(healthbar.value<=0)
Destroy(GetComponent<BoxCollider>());
}
if(healthbar.value<=0)
{
HP.SetActive(false);
}
else
{
HP.SetActive(true);
}
}
}
}
}
void Update()
{
if (Input.GetButton("Fire1"))
{
anim.SetBool("isHit", true);
}
else
anim.SetBool("isHit", false);
}
}
Thank you.
ps. Sorry for my bad English