Unity: Finally understand Get Component
Learn what are components and how to use the GetComponent function in different ways. Also, learn how to avoid common mistakes.
✅ Get my courses with discount:
👉 Unity 2D Master: www.udemy.com/course/unity2dm...
👉 Unity Mobile Course: www.udemy.com/course/unitymob...
👉 Unity Input System with Rebinding: www.udemy.com/course/unity-in...
👍 Save your time and learn Unity faster
-------------------------------------------------------
🔔 Subscribe for more awesome content:
🔴 / @rootgames
-------------------------------------------------------
🟡 Support this channel through donations
Any amount means a lot and will help grow the channel:
👉 PayPal: www.paypal.com/paypalme/rootg...
-------------------------------------------------------
Social Networks:
⭐ Instagram: / rootgamesofficial
⭐ Twitter: / rootgamescro
⭐ TikTok: www.tiktok.com/@rootgamesoffi...
⭐ Facebook: / root-games-10337038860...
-------------------------------------------------------
0:00 Intro
0:18 Components
1:12 GetComponent Function
2:54 Collision and GetComponent
4:48 No Collision and GetComponent
5:55 GetComponent Children/Parent
6:30 Tips
#getcomponent #unitytutorial #unity #rootgames
Пікірлер: 39
✅ Get my courses with discount: 👉 Unity 2D Master: www.udemy.com/course/unity2dmaster/?couponCode=SMOOTH-2D-MASTER 👉 Unity Mobile Course: www.udemy.com/course/unitymobilecourse/?couponCode=SMOOTH-MOBILE 👉 Unity Input System with Rebinding: www.udemy.com/course/unity-input-system-rebind/?couponCode=SMOOTH-OFFER-INPUT
Bite size training for big sized results. Love the content, keep it coming. Maybe throw out some ideas at the end of different things you can do with the same coding to get our imaginations going! Thank you!
The timing on your Subscribe Bell and the "Eureka" moment I had watching this was impeccable LMAO, Thanks for the great tutorial :)
Thank you soooooo much! This really helped! ❤️
Perfect explanation
wow, you just help me alot God bless you
@RootGames
7 ай бұрын
Glad to help 😉
Well explained sir
Отличный видос! Всё понятно и доходчиво, спасибо тебе, мой английский друг)
@RootGames
2 жыл бұрын
Спасибо! 😊
super helpful thank you!
@RootGames
Жыл бұрын
Glad to help! 🙂
! SUPERB!
That's great tutorial. But I have a question that can't we use components of cube gameobject directly using GetComponent(); without using tags. Please help!!!
Lit video bro
Excelent tutorial, thank you very much. Big regards from Serbia!!! 👋👋👋
@RootGames
9 ай бұрын
Thanks for the support!
on Get component without collision should we call on start or on awake ?? I see you call on start but I´d like to know if there is any diference in doing so as far the performance
@RootGames
Жыл бұрын
For a modern PC, it really doesn't matter. Maybe for mobile it's better to use Awake more. In general, I combine Start and Awake, some things in the Awake that must be called before, and some things in the Start.
the piece with "findGameObjectWithTag" made it click for me
Can you please tell Is there a way to change some properties of other game objects by using GetComponent() in the same script . If so, How we can do that?
@RootGames
Жыл бұрын
You can use tags to get component from the object you want, or you can just make public (or [SerializeField])variable and drag that component into the slot in the Inspector.
@vishnuppriyaj5886
Жыл бұрын
@@RootGames Thanks !
How would i be able to use get component when i have two box colliders? How would i be able to distinguish between them? I couldnt find answers elsewhere please help
@RootGames
Жыл бұрын
Then you need to use [SerializeField] and drag the specific collider you want to use.
very nice
@RootGames
Жыл бұрын
Thanks 🙂
why we don't make instance of a class , like you made an spriterenderer object but you don't instantiate it by = new spriterenderer() line
@RootGames
2 жыл бұрын
Because I don't want to use a new spriterenderer component. I want to get the spriterenderer component that sits on the object.
@theslinkbeast1086
2 жыл бұрын
@@RootGames thanks for clearing my doubt
Im a complete beginner, and I'm having trouble with the Transform component, why doesn't it show up as blue or any other color except white when I type it out????
@RootGames
Жыл бұрын
Did you change the name of the script maybe? If not, Unity and Visual Studio lost connection. Go to Unity-> Edit -> Preferences -> External Tools Make sure that Visual Studio is selected as External script editor, and you can click on the "Regenerate project files" button.
Why get Component Lagging problem
@RootGames
2 жыл бұрын
If you use it correctly (not in the Update method) you will not have any problems, even on mobile.
when i do this , my sprite was loss color ?
2:51 my sprite was loss color
@testaqlk6173
6 ай бұрын
Hello... when you choose a new color from colorpicker, you need to change Alpha to 255 (default is 0).. this is the reason why your object "disappear"