At the moment I'm trying to use an array to check each element's tag and change that object's Box Collider 2D state for each one I want. At the moment the size of the array is 7 where each element has a Game Object selected.
using UnityEngine;
using System.Collections;
public class scrHitboxStateUpdate : MonoBehaviour
{
public GameObject[] arrCollection;
void Update()
{
for (int i = 0; i >= 6; i++)
{
if (arrCollection[i].tag == ("GameObject")) //Where object triggers will not be used
{
arrCollection[i].GetComponent().enabled = false;
}
else if (arrCollection[i].tag == ("TriggerObject")) //Where object triggers will be used
{
arrCollection[i].GetComponent().enabled = true;
}
}
}
}
However, when I execute the script the objects' BoxCollider2D enable state remains unchanged and no errors show up in the console. I'm pretty confused as I'd expect this to work.
↧