Question by
virendramarshall · Aug 04, 2018 at 04:12 AM ·
assign-variable
how to change the value of the script which is added to the multiple object? please help..
i have five guard in the scene which has the same script fyi. guard is a prefab. and i want to change the value of all the guards when my player hit the powerup. right now im doing this im just assigning all differently.
IEnumerator PickUp(Collider player) { if (player.tag == "other") {
if (rend.material.shader == shader1) {
rend.material.shader = shader2;
}
}
visPower.GetComponent<MeshRenderer>().enabled =false;
visPower.GetComponent<Collider> ().enabled = false;
boss.viewMask = 1 << LayerMask.NameToLayer ("Player");
g1.viewMask = 1 << LayerMask.NameToLayer ("Player");
g2.viewMask = 1 << LayerMask.NameToLayer ("Player");
g3.viewMask = 1 << LayerMask.NameToLayer ("Player");
g4.viewMask = 1 << LayerMask.NameToLayer ("Player");
boss.speed = 5f;
yield return new WaitForSeconds (duration);
rend.material.shader = shader1;
boss.viewMask = 1<<LayerMask.NameToLayer("obstacle");
g1.viewMask = 1<<LayerMask.NameToLayer("obstacle");
g2.viewMask = 1<<LayerMask.NameToLayer("obstacle");
g3.viewMask = 1<<LayerMask.NameToLayer("obstacle");
g4.viewMask = 1<<LayerMask.NameToLayer("obstacle");
boss.speed = 15f;
Destroy (GameObject.FindWithTag ("other"));
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612172153im_/https://answers.unity.com/themes/thub/images/avi.jpg)