How can I let a trigger detect if a collider is inside (at start)

Hi everybody

I am currently building a game about being on another planet and such…
Whenever the player is in a safezone, the player will be able to recharge the oxygen they are carrying around. I’ve got the safezone setup, but I only want it to be able to work whenever a oxygengenerator is inside of it.

Since the building in which the oxygen generator is able to stand in, is a prefab (just as the oxygen generator), I want to be able to my every safezone/building to check for themself if an oxygen generator is placed in the safezone/building.

How can I achieve this?

Thanks upfront!

EDIT

I might forgot to mention that the player is a seperate game object. The player is able to walk in and out of the safezone, though the generator cannot move when playing the game. (It can be build however).

I’ve tried using OnTriggerStay with a tag, but this is not working. By default, some zones already have some generators in them.

Good day.

You have the OnTriggerStay() funtion, which will be executed when a collider is inside the trigger of the gameobject (every frame).

Thena good solution is to create a tag for OxigenGenerator Object fro example “OxiGen”, and check if the collider that is inside have this tag.

void OnTriggerStay(Collider other)
    {
        if (other.gameObject.tag == "OxiGen")
        {
            Debug.Log ("Oxigen generator detected!!");
        }
    }

Byeee!