My question is simple, how to access my gameobjects custom C# script through a foreach.
I’ve tried following:
foreach(TowerController go in GameObject.FindGameObjectsWithTag("Tower")) {
go.upgradeTowerProgress = false;
}
Doesn’t seems to work. Dunno why, that’s why im here to ask! xD
TowerController is my custom script on the gameObjects with tag Tower.
This should work (untested):
What I changed is that you are iterating a GameObject array, so you need to do
foreach(GameObject go..., then you use the GetComponent function to get the component that is of the typeTowerControllerand then you can access itsupdateTowerProgress. THIS page is always a good reference.