Hello,
I have am npc that follows the player. What I want to have happen is when an enemy enters the trigger (that is surrounding the npc) I want the npc to go after that specific enemy. I have many enemies in the scene. how would I do this? (A tutorial video would be helpful.
If your fellow NPC has a Collider in trigger mode. You can use the method :
void OnTriggerEnter(Collider other) { }
The code you’re looking at may be something like :
void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Enemy"))
{
navAgent.SetDestination(other.transform.position);
}
}
Of course the enemies must be tagged “Enemy”.