private void OnTriggerEnter2D(Collider2D other) { if (other.GetComponent <TeamData>()) { if (other.GetComponent <TeamData>().GetTeamBelonging() != teamData.GetTeamBelonging()) { triggered = true; if (spawningTrigger) { // Activate trigger unitSpawner.StartSpawning(); boxCollider.enabled = false; return; } if (trapTrigger) { enemyTrap.TriggerTrap(); boxCollider.enabled = false; } } } }