Search Unity

OnTriggerExit Bugs <Internal error: Too many pairs created, new pairs will be ignore>

Discussion in 'Scripting' started by felix85, Feb 28, 2012.

  1. felix85

    felix85

    Joined:
    Sep 24, 2010
    Posts:
    24
    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.

    PHP:
    function OnTriggerExit(collider Collider){

      if(
    collider.gameObject.tag == "RoadObject" || collider.gameObject.tag == "RoadObject_Bend")
          
    CalculateNextTurnRoad();
    }

    function 
    CalculateNextTurnRoad(){

       
    _roadType Random.Range(02);

       if(
    _roadType == 1)
          
    GenerateRoad(1);

       else
          
    GenerateRoad(0);




    function 
    GenerateRoad(roadType:int){

       
    //Instantiating new GameObject from Resources Folder.

    }
     
  2. felix85

    felix85

    Joined:
    Sep 24, 2010
    Posts:
    24
    Problem Solved. 3D Mesh is not in good shape, resulting flaws in Mesh Collider. Therefore, I put a Box Collider for the road model instead of using Mesh Collider. Hope this will help others who encounter this problem in future.