I’m writing a script to make NPCs randomly select another NPC to talk to. Currently I’m using the following:
AIPath npcPath = npc.GetComponent<AIPath> ();
GameObject[] desiredObject = GameObject.FindGameObjectsWithTag("NPC");
Transform[] desiredTransforms = Array.ConvertAll<GameObject, Transform>(desiredObject, x => x.transform );
npcPath.target = desiredTransforms(UnityEngine.Random.Range(0, desiredTransforms.Length);
The problem is, there is nothing preventing the NPC from talking to himself. Is there an easy way to exclude the NPC the script is attached to from the findgameobjectswithtag call?