What Does It Mean By GetComponent & How do you Use It?!
What does it mean by GetComponent?
I found out that it means : To access/get other scripts or components in a GameObject or other GameObjects.
But can you please define what it means by this and how you use it (I'm not an English Expert), so please explain as clearly as possible and please answer!
Have you done the basic C# tutorials? You have to walk before you can run, you know? https://unity3d.com/learn/tutorials/topics/scripting/coding-unity-absolute-beginner
I agree with @Pinkuboxu , you have to walk before you can run.
Drop me a line through my website, I'll point you to some resources if you want.
Answer by Paodimelaun · Jul 08, 2018 at 05:22 PM
it's basically used as a way to get a variable(component) from the object the script is attached or to any object that you can acces trough that script. Let's assume you have a script called PlayerMovement wich is attached to your player, that player object has a rigidbody on it, you can acces that rigidbody values and methods by using GetComponent<Rigidbody>();
you can use it as an instance of your rigidbody, therefore you're able to change its values and do everything else a rigidbody allows you to do. For example, you can change the Player rigidbody mass from inside the playerMovement script, by typing: GetComponent<Rigidbody>().mass = 10;
in short, it's basically a way to access the various types of components of the engine.
Your answer
Follow this Question
Related Questions
What Does GetComponents mean & What does it do?! 2 Answers
how could I make a bool true and make other bools false? 1 Answer
Word guessing game 1 Answer
Checking if Keyboard input was an integer 0 Answers
C# Script question 0 Answers