Unity: Finally understand Get Component

  Рет қаралды 21,883

Root Games

Root Games

Күн бұрын

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
@RootGames
@RootGames Жыл бұрын
✅ Get my courses with discount: 👉 Unity 2D Master: www.udemy.com/course/unity2dmaster/?couponCode=NEW-MASTER-MAY 👉 Unity Mobile Course: www.udemy.com/course/unitymobilecourse/?couponCode=MOBILE-MAY 👉 Unity Input System with Rebinding: www.udemy.com/course/unity-input-system-rebind/?couponCode=NEW-INPUT-MAY
@trevor3233
@trevor3233 2 ай бұрын
Thank you soooooo much! This really helped! ❤️
@birthdaythesuit00
@birthdaythesuit00 Жыл бұрын
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!
@Kwuasimoto
@Kwuasimoto Жыл бұрын
The timing on your Subscribe Bell and the "Eureka" moment I had watching this was impeccable LMAO, Thanks for the great tutorial :)
@mdrafik2330
@mdrafik2330 5 ай бұрын
wow, you just help me alot God bless you
@RootGames
@RootGames 5 ай бұрын
Glad to help 😉
@keyable
@keyable Жыл бұрын
Perfect explanation
@DanyaDanechka26
@DanyaDanechka26 2 жыл бұрын
Отличный видос! Всё понятно и доходчиво, спасибо тебе, мой английский друг)
@RootGames
@RootGames 2 жыл бұрын
Спасибо! 😊
@betafishie
@betafishie Жыл бұрын
super helpful thank you!
@RootGames
@RootGames Жыл бұрын
Glad to help! 🙂
@techplatform5100
@techplatform5100 Жыл бұрын
Well explained sir
@ayushsidam289
@ayushsidam289 Жыл бұрын
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!!!
@hvm3164
@hvm3164 Жыл бұрын
! SUPERB!
@kiPROBRos
@kiPROBRos 7 ай бұрын
Excelent tutorial, thank you very much. Big regards from Serbia!!! 👋👋👋
@RootGames
@RootGames 7 ай бұрын
Thanks for the support!
@gamesbyspinola
@gamesbyspinola Жыл бұрын
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
@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.
@hvm3164
@hvm3164 Жыл бұрын
the piece with "findGameObjectWithTag" made it click for me
@vishnuppriyaj5886
@vishnuppriyaj5886 Жыл бұрын
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
@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
@vishnuppriyaj5886 Жыл бұрын
@@RootGames Thanks !
@brucelee7782
@brucelee7782 Жыл бұрын
Lit video bro
@kayzoku1
@kayzoku1 Жыл бұрын
very nice
@RootGames
@RootGames Жыл бұрын
Thanks 🙂
@venomradar
@venomradar Жыл бұрын
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
@RootGames Жыл бұрын
Then you need to use [SerializeField] and drag the specific collider you want to use.
@theslinkbeast1086
@theslinkbeast1086 2 жыл бұрын
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
@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
@theslinkbeast1086 2 жыл бұрын
@@RootGames thanks for clearing my doubt
@cattobean63
@cattobean63 10 ай бұрын
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
@RootGames 10 ай бұрын
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.
@suryaprakash9083
@suryaprakash9083 2 жыл бұрын
Why get Component Lagging problem
@RootGames
@RootGames 2 жыл бұрын
If you use it correctly (not in the Update method) you will not have any problems, even on mobile.
@thuanyeumh
@thuanyeumh Жыл бұрын
when i do this , my sprite was loss color ?
@thuanyeumh
@thuanyeumh Жыл бұрын
2:51 my sprite was loss color
@testaqlk6173
@testaqlk6173 4 ай бұрын
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"
Unity Localization: Add support for Multiple Languages [1/2]
8:59
The delivery rescued them
00:52
Mamasoboliha
Рет қаралды 6 МЛН
КАХА и Джин 2
00:36
К-Media
Рет қаралды 4,2 МЛН
UFC 302 : Махачев VS Порье
02:54
Setanta Sports UFC
Рет қаралды 1,3 МЛН
He tried to save his parking spot, instant karma
00:28
Zach King
Рет қаралды 18 МЛН
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 677 М.
The Power of Scriptable Objects as Middle-Men
17:41
samyam
Рет қаралды 116 М.
Better Coding in Unity With Just a Few Lines of Code
15:27
Firemind
Рет қаралды 301 М.
What are Events? (C# Basics)
15:05
Code Monkey
Рет қаралды 373 М.
10 Things You NEED to Be Doing in Unity
11:40
Tarodev
Рет қаралды 125 М.
SCRIPTABLE OBJECTS and EVENTS in Unity
6:46
Root Games
Рет қаралды 2,8 М.
20 Advanced Coding Tips For Big Unity Projects
22:23
Tesseract
Рет қаралды 154 М.
Better Jumping in Unity With Four Lines of Code
12:47
Board To Bits Games
Рет қаралды 817 М.
Breaking up Code in Unity (Important game dev tips for beginners)
18:36
Lost Relic Games
Рет қаралды 123 М.
The delivery rescued them
00:52
Mamasoboliha
Рет қаралды 6 МЛН