in the game I am doing atm you have an area with monsters. There are two modes to damage monsters :
- tapping on them
- casting spells on the ground
Tapping and damaging a monster works fine.
The problem : If I have selected a spell and want to cast it on the ground, the monster collider blocks my touch of the ground behind the monster.
My solution was to disable the monster collider when I want to cast a spell.
GameObject[] toDisable = GameObject.FindGameObjectsWithTag ("Touch");
foreach (GameObject g in toDisable) {
g.GetComponent<Collider>().enabled = active;
}
And ... it works.
Now my question is : Is this an adequate solution? They say GetComponent is slow, but I guess with 20 to 30 monsters running around it should be fine? Anything else that could be done? Maybe there is some Unity magic I am not aware of.