I’ve been creating a sighting system which will add players to an array of seen targets if they come within the trigger and then i’ll be doing some raycasting to check weather they’re in front of me. The problem i’m having is adding the object to the list if it isn’t in the list. The way it hopefully will work is this line will be called when an enemy has wandered into the trigger(by the enemy)
function OnTriggerEnter(other : Collider)
{
target.gameObject.SendMessage("AddToArray", gameObject,SendMessageOptions.DontRequireReceiver);
}
and this is called by the ally when the enemy sends the message
import System.Collections.Generic;
var enemies : List.<GameObject>;
function AddToArray (newTarget : GameObject)
{
enemies.Add(newTarget);
}
As I said there was no error, just I want it to add the enemy to the list, if it isn’t in the list
thanks in advanced