Hello everyone. I’m working on a game for Android where the player needs to touch some objects spawning on random locations before they auto-disappear. The problem I’m having is with deactivating the objects:
IEnumerator DestroyCircles ()
{
foreach (GameObject o in circles) //Where circles is a List<GameObject>
{
yield return new WaitForSeconds (destroyTime);
circles[o].SetActive (false);
}
yield break;
}
I get the following two errors:
-
The best overloaded method match for `
System.Collections.Generic.List<UnityEngine.GameObject>.this[int]’ has some
invalid arguments; -
Argument
#1' cannot convert
UnityEngine.GameObject’ expression to type `int’.
For the first error, it doesn’t work if I convert
“o” to an int (obviously).
How should I go about this?
Any help is greatly appreciated.