GetComponent, What is it ?

Hi everyone, Can you help me to know the main meaning of this function ?

  • We use it when ?

Thanks and Best Regards

That’s a function which is used to access some component from some game object which it is attached to. If you will use that component, which you’re trying to get, more than once in your script then you can store the reference to that component in your script for further uses, which will be beneficial for performance.

You should also check out THIS DOCUMENTATION and THAT TUTORIAL for better understanding.

Also next time when you’ll have such simple question - try to search through API / MANUAL and try to go through TUTORIALS.