Hello everyone, I have 4 spawn points in my game. What I want is, I made a huge invisible cube in front of my camera, and made it trigger. So it detects the spawn points in front of the player. ( note : as a spawn point, I used some objects which has collider in my level ) I want my code to check the spawn points which player does not see ( it will be detected by the collider object that is infront of my camera ) , and randomly choose one of that non seen by player spawn points. So I made a logic like that, I would remove the object which my collider touches from array and then go on RandomRange to the left objects in array. But I really have big problems about array, can some one help me with my code ?
#pragma strict
var spawns : GameObject;
var indx : int;
function OnTriggerEnter (c: Collider) {
if(c.tag=="Spawn")
{
indx = c.gameObject.GetComponent(SpawnScripts).id; // I made an int value for every spawn
// point so I'd know which spawn collider touches
spawns.RemoveAt (indx); // remove array, and here I got stuck
}
}