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

  • @RootGames
    @RootGames Жыл бұрын

    ✅ 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

  • @birthdaythesuit00
    @birthdaythesuit002 жыл бұрын

    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 :)

  • @trevor3233
    @trevor32333 ай бұрын

    Thank you soooooo much! This really helped! ❤️

  • @keyable
    @keyable Жыл бұрын

    Perfect explanation

  • @mdrafik2330
    @mdrafik23307 ай бұрын

    wow, you just help me alot God bless you

  • @RootGames

    @RootGames

    7 ай бұрын

    Glad to help 😉

  • @techplatform5100
    @techplatform51002 жыл бұрын

    Well explained sir

  • @DanyaDanechka26
    @DanyaDanechka262 жыл бұрын

    Отличный видос! Всё понятно и доходчиво, спасибо тебе, мой английский друг)

  • @RootGames

    @RootGames

    2 жыл бұрын

    Спасибо! 😊

  • @betafishie
    @betafishie Жыл бұрын

    super helpful thank you!

  • @RootGames

    @RootGames

    Жыл бұрын

    Glad to help! 🙂

  • @hvm3164
    @hvm3164 Жыл бұрын

    ! SUPERB!

  • @ayushsidam289
    @ayushsidam2892 жыл бұрын

    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!!!

  • @brucelee7782
    @brucelee7782 Жыл бұрын

    Lit video bro

  • @kiPROBRos
    @kiPROBRos9 ай бұрын

    Excelent tutorial, thank you very much. Big regards from Serbia!!! 👋👋👋

  • @RootGames

    @RootGames

    9 ай бұрын

    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 !

  • @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.

  • @kayzoku1
    @kayzoku1 Жыл бұрын

    very nice

  • @RootGames

    @RootGames

    Жыл бұрын

    Thanks 🙂

  • @theslinkbeast1086
    @theslinkbeast10862 жыл бұрын

    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 Жыл бұрын

    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

    Жыл бұрын

    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
    @suryaprakash90832 жыл бұрын

    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
    @thuanyeumh2 жыл бұрын

    when i do this , my sprite was loss color ?

  • @thuanyeumh
    @thuanyeumh2 жыл бұрын

    2:51 my sprite was loss color

  • @testaqlk6173

    @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"