- Home /
Question by
Manco Capac · Dec 04, 2013 at 01:15 PM ·
gameobjecttriggergetcomponent
GetComponent of copies of one gameobject?
I have a range of gameobjects which make up a fence. I want to disable a script in all the gameobjects when the player triggers a collider. What's the easiest way to do this? I was trying to do this from a script in the collider gameobject, but i didnt manage to do anything. : / is it possible to get same components in multiple gameobjects?
any ideas?
Comment
you could use:
foreach (Gameobject allObjects in GameObjects.FindGameObjectsWithTag("fences"))
allObjects.GetComponent<BoxCollider>().enabled = false;
@ahaykal - I suppose you posted a generic version of GetComponent, but to properly display
GetComponent<xxxx>
you have to format the code.
@ArkaneX I was sure I wrote it this way first :). Thank you in all cases
Your answer
![](https://koobas.hobune.stream/wayback/20220613123411im_/https://answers.unity.com/themes/thub/images/avi.jpg)