Ejemplo n.º 1
0
    //----this is the exact opposit of OnTriggerEnter
    private void OnTriggerExit(Collider other)
    {
        if (other.CompareTag("Building") || other.CompareTag("Wall"))
        {
            obj.Remove(other.gameObject);//----notice we're removing it from the list
        }

        if (other.CompareTag("GroundCube"))
        {
            GroundCube gc = other.GetComponent <GroundCube>();
            cubes.Remove(gc);//----removing it from the list
            gc.HandleSelection();
        }
        ChangeColor();
    }
Ejemplo n.º 2
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Building") || other.CompareTag("Wall")) //hit a building or a wall?......
        {
            obj.Add(other.gameObject);                                //then stick it in the obj list.....
        }

        if (other.CompareTag("GroundCube"))                    //hit a ground cube?.........
        {
            GroundCube gc = other.GetComponent <GroundCube>(); //get the ground cube script that is sitting on this particular gameobject.....
            cubes.Add(gc);                                     //add it to the ground cubes list....
            gc.HandleSelection();                              //toggle the selection color of this particular ground cube......
        }
        ChangeColor();                                         //<----no check if the color should be green or red
    }