Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Cloned triggers of same tag help

Discussion in 'Editor & General Support' started by Vintage_Green, Sep 24, 2015.

  1. Vintage_Green

    Vintage_Green

    Joined:
    Mar 27, 2015
    Posts:
    22
    Lets say I have a grid of cloned cubes/triggers that are children of the terrain in a grid of 3X3.
    The TriggerCubes are infinitely (Cloned) for each Terrain piece in the 3X3 grid space.
    I'm using an infinite terrain script that also clones all children.

    The problem is that I want each trigger to not be able to be triggered more than once but I also don't want them to disable or else they wont be cloned anymore.

    EX: I walk into a terrain 1X1 section of the 3X3 grid in that section it has one of the cloned TriggerCubes with the Tag "TriggerGM_" I want to be able to count each time the player has gone into one of these TriggerCubes by using an Int Counter TriggerCounter_01 ++; the thing is with the TriggerCube still active the player can exploit it and just go back and forth.

    Is there a way to disable theCollision.gameObject.SetActive(false); and store it so that when I hit the next Trigger Collider of the same name(cloned) and Tag it enables the one behind me that I just deactivated?



    void OnTriggerEnter(Collider theCollision)
    {
    if (theCollision.gameObject.tag == "TriggerGM_")
    {
    TriggerCounter_01 ++;
    Debug.Log("Hello inside Trigger");

    theCollision.gameObject.SetActive(false);

    }

    }

    edit I used
    Random.Range as a workaround all good
     
    Last edited: Sep 25, 2015