When the game start, a piece of road will translating and when it is OnTriggerExit from a collider(Used for detection), it will randomly generate a new straight road, or bended road, to continue the path of previous one.
The problem is, sometime when I click play button in Unity3D to start the game, after the OnTriggerExit is triggered, the system will suddenly generate a lot of the roads from resources folder, resulting <Internal error: Too many pairs created, new pairs will be ignored. This is perhaps due to an excessive number of objects created at one location.: >, but sometimes it won’t encounter this problem. Is this a bug of the Unity3d? Please help. Thank you.
function OnTriggerExit(collider : Collider){
if(collider.gameObject.tag == "RoadObject" || collider.gameObject.tag == "RoadObject_Bend")
CalculateNextTurnRoad();
}
function CalculateNextTurnRoad(){
_roadType = Random.Range(0, 2);
if(_roadType == 1)
GenerateRoad(1);
else
GenerateRoad(0);
}
function GenerateRoad(roadType:int){
//Instantiating new GameObject from Resources Folder.
}