Need help with setting all items of a specific tag to "inactive" when i die.

I am making a platform level and my death trigger looks like this. the level is based around hitting switches to activate the next platform. but when i die, i want the platforms to go back to how they were when the level started, inactive.


var spawn : Transform;
var platforms : GameObject[];

platforms = GameObject.FindGameObjectsWithTag("platforms");

function OnTriggerEnter(other : Collider)
{
    if (other.tag == "Player")
    {
       
        other.transform.position = spawn.position;
        audio.Play();
        platforms.SetActive(false);
    }
    
}

I want the game objects with the tag “platforms” to be set to inactive when i cross the death trigger, effectively starting the level over.

but right now, nothing is happening, im respawning, but the platforms are still active.

can you offer any help?

1 Answer

1

platforms is an array of GameObjects. Are you sure you can do platforms.SetActive(false); without iterating over each item inside an array?