accesing multiple objects that share the same script from another script
hello, i realize that there are other "similar" questions out there, but none of them are useful for me, or maybe they are but my limited understanding of c# gets on the way :p. now, I made a trap door on the ground that slides off once its "touch count" is depleted. it stays that way until the player dies (I'm not actually resetting the scene, just moving the player back to spawn). I'm using a game manager that handles timer, amount of coins gathered etc. this is also where I'm calling the "death" function (to keep track of the amount of deaths). i tried adding a public gameobject (on the game manager script) to quote the trapdoor, reset it's "touch count" and position, and it works flawlessly... so long as there's only one of them. now, how would you recommend doing this? resetting multiple objects (which I've tagged "reset") from the game manager???
//this is the (relevant) script from the game manager
public Trap_Platform_Controller resets;
public bool hasPlatforms = true;
public void addDeath()
{
deathCount += 1;
if (hasPlatforms == true) {
resets.touches = 2;
resets.transform.position = resets.spawn;
}
}
GameObject [] obj;
Trap_Platform_Controller resets;
public bool hasPlatforms = true;
public void addDeath()
{
deathCount += 1;
if (hasPlatforms == true)
{
obj = GameObject.FindGameObjectsWithTag ("reset");
for (int i = 0; i < obj.Length; i++)
{
resets= obj [i].GetComponent<Trap_Platform_Controller>();
resets.touches = 2;
resets.transform.position = resets.spawn; // how this line work !
}
}
}
resets is a reference for Trap_Platform_Controller script not transform so explane .