- Home /
How do you trigger components from different objects?
I've set up a area where when the player stands in a certain area it activates a light. However I can't seem to get the light to activate I have the trigger set up (and it registers), however how do I get the light to turn on or any component in a separate object.
Put a script with OnTriggerEnter() and OnTriggerExit() on the area. use a public variable (Transform) where you drag in the light in the inspector. Then in OnTriggerEnter you may want to check if othercollider == player(maybe by name, tag or layer) then light.enabled = true or however you like to turn on and off your light. OnTriggerExit respectively.
Answer by echofiend · Jan 10, 2013 at 12:21 AM
You will need to use
GameObject.Find("Name of your light")
in order to grab your light in the scene. Then you will need to use the standard GetComponent and such to activate anything, or operate on it.
Your answer
![](https://koobas.hobune.stream/wayback/20220613090659im_/https://answers.unity.com/themes/thub/images/avi.jpg)