Reply To: Ok this course is my first time scripting so bear with me. I got this exercise to work fine by copying your script. But …

Forum Archive Ok this course is my first time scripting so bear with me. I got this exercise to work fine by copying your script. But … Reply To: Ok this course is my first time scripting so bear with me. I got this exercise to work fine by copying your script. But …

#23015
Jonathan Gonzalez
Participant

    A component is essentially just a script. So we can access specific functions/variables made public within that script as long as we make a reference to it within our script. So intensity and range are both specific to the light component and we can access them. 

    When we use GetComponent we’re telling Unity to cache that specific component so we can access parts of that component. Note that previously Unity would have certain component that could be accessed without using GetComponent but in general it’s a good idea to use it to cache it yourself. 

     It would be similar if we had our own custom script and we wanted to access things within that script from an external script. Hope that makes sense.