Hi guys,
I am using a sphere collider on a gameobject with a character controller to represent my in-game enemies. I have a snippet of code that checks all gameobjects that enter the sphere and adds them to an array for a list of possible targets. See below:
void OnTriggerEnter(Collider other){
Debug.Log(other.name);
for(int i = 0; i < 30; i++){
if(targetList *== null){*
_ targetList = other.gameObject;_
* ChoosePrimaryTarget(); *
* return;*
* }*
* } *
* }*
my problem is, at runtime, it is adding 2 instances of itself to its target array. I’m not sure where these are coming from or why there are 2. Its only started happening since I added the character controller, so I know it has something to do with that. I just dont fully understand what is going on. I would think OnTriggerEnter would pull 1 at most. no other colliders are attached.
Thanks!