I want to update my NPC target, if the target enter in the sphere collider of my NPC, It will attack the target.
If target death, I will attack the next target in range. But some how my NPC wont attack the next target in range until the death target was destroyed. I add a front game ob to check which is death or not but look like the target of my NPC won’t update until the death target destroy !
GameObject CurrentTarget;
void OnTriggerEnter (Collider target){
if (target.gameObject.tag == ChaseEnemyTag && target.gameObject.transform.GetChild (0).name == "front") {
CurrentTarget = target.gameObject;
}
}
I also tried
GameObject CurrentTarget;
void OnTriggerEnter (Collider target){
if (target.gameObject.tag == ChaseEnemyTag && target.gameObject.transform.GetChild (0).name == "front") {
CurrentTarget = target.gameObject;
}
else{
CurrentTarget = null;
}
}
How to make the CurrentTarget update if the last is death ? Thank you