public void EnableAllTraps() { GameObject[] triggersGO = GameObject.FindGameObjectsWithTag("Threat"); foreach (GameObject go in triggersGO) { Trap trapGO = go.GetComponent <Trap>(); if (trapGO != null) { trapGO.EnableTrap(); } } }