How would I use GetComponent to change variables in other scripts? I understand the concept behind it, but I cannot setup the script in the right format. I used this (Unity - Scripting API: GameObject.GetComponent)
to set up my script. This is the line of code I am having trouble with:
transform.Find(“box”).GetComponent(lighttoggle).light = true;
In this part of the code, there is a box (gameobject), with a script attached called lighttoggle, With a var (bollean) called light.
But, when I attach the script to the player, the script does not turn on the light. The script works when I attach another trigger to it (Input.GetKeyDown), so the problem is the GetComponent. Can someone tell me how to format the GetComponent so that it will work?
Please don’t ask me if I Googled it, I did.
I will be grateful for any help.
Javascript only, please
-Thanks