I want to make game that looks like Rocket Mania, it almost done but something was wrong with the TriggerExit. and now i and my team was stuck and dont know how to continue this game.
Maybe same of you guys please help us to make this game out?

No code. No help... Post the relevant code where you are having a problem.

public bool isConnectAll = false;

public GameObject [] newObstacle;

public float speed = 0.001f;

int obj = 0;

Vector3 posObs;

private Transform posY;

public List<GameObject> Obstacle = new List<GameObject>();

void Start () {

}


void Update () {

    if (isConnectAll == true){
        for (obj = 0; obj < Obstacle.Count; obj++) {
            posObs = new Vector3 (Obstacle[obj].transform.position.x, Obstacle[obj].transform.position.y, Obstacle[obj].transform.position.z);
            Destroy(Obstacle[obj]);
            SpawnObs();
            //StartCoroutine(secondBetween(1));
        }
        Obstacle.Clear();
        isConnectAll = false;
    }


}

void OnTriggerEnter2D(Collider2D other){
    if (other.tag == "Balok"){
        Obstacle.Add(other.transform.parent.gameObject);
        other.transform.parent.GetComponent<PipaRotate>().Check = this;
    }
}

void OnTriggerExit2D(Collider2D other){
    if (other.tag == "Balok"){
        Obstacle.Remove(other.transform.parent.gameObject);
        other.transform.parent.GetComponent<PipaRotate>().Check = null;
        Obstacle.Clear();
    }
}

public void SpawnObs(){
    int i = Random.Range(0,newObstacle.Length);
    Instantiate (newObstacle[i], posObs, Quaternion.identity);
}

//That's for checking the first obstacle with the startList

public bool isConnected = false;

public PipaRotate ThisPipe;

void Start () {
    ThisPipe = transform.parent.GetComponent<PipaRotate>();  
}

void Update () {

}

void OnTriggerStay2D(Collider2D other){
    if (other.tag == "Balok"){

        isConnected = true;

        if (other.transform.parent.GetComponent<PipaRotate>().Check == null && ThisPipe.Check != null){
            ThisPipe.Check.Obstacle.Add(other.transform.parent.gameObject);
            other.transform.parent.GetComponent<PipaRotate>().Check = ThisPipe.Check;
            /*bool isEnter = false; 

            for (int i = 0; i < ThisPipe.Check.Obstacle.Count; i++) {
                if (ThisPipe.Check.Obstacle[i] == other.transform.parent.gameObject){
                    isEnter = true;
                }
            }
            if (isEnter == true){
                ThisPipe.Check.Obstacle.Add(other.transform.parent.gameObject);
                other.transform.parent.GetComponent<PipaRotate>().Check = ThisPipe.Check;
            }*/
        }
    }

    if (other.tag == "Akhir"){
        if (ThisPipe.Check !=null){
            ThisPipe.Check.isConnectAll = true;
        }
    }
}

void OnTriggerExit2D(Collider2D other){
    if (other.tag == "Balok"){

        isConnected = false;

        if (ThisPipe.Check != null){
            int indexPipe = ThisPipe.Check.Obstacle.IndexOf(other.transform.parent.gameObject);
            for (int i = ThisPipe.Check.Obstacle.Count - 1; i == indexPipe; i--) {
                ThisPipe.Check.Obstacle[i].GetComponent<PipaRotate>().Check = null;
                ThisPipe.Check.Obstacle.RemoveAt(i);
            }

        }
    }

//That's for checking the other obstacles with the first obstacle
pipe.png

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.