Unity - Call a method/function from another script

Поделиться
HTML-код
  • Опубликовано: 1 фев 2025

Комментарии •

  • @potatobrother1933
    @potatobrother1933 Год назад +13

    After lots of pain, this tutorial made it seem so easy! Super concise, addressing the specific issue clearly and very effectively. Thanks a bunch!

  • @oscxrl
    @oscxrl 2 года назад +4

    THANK YOU! This is such a simple thing but I was yet to find a simple tutorial as I am very new to unity, no other tutorial has explained it this well. Thank you so much!

    • @DA-LAB
      @DA-LAB  2 года назад +2

      Glad it helped!

  • @toastgames9028
    @toastgames9028 2 года назад +3

    Thanks, absolutely great video you got right to the point, other videos a saw stuffed around for ages and i loved how you actually had name for things that werent just letter. this helped so much thanks a lot

    • @DA-LAB
      @DA-LAB  2 года назад

      Thank a lot. That is wonderful to hear.

  • @sampreetsingh3687
    @sampreetsingh3687 Год назад

    this video singlehandedly saved me hours on GMTK game jam! thank you!

    • @DA-LAB
      @DA-LAB  Год назад

      I am glad it helped :)

  • @goldchn
    @goldchn 10 месяцев назад

    You are the goat. Such an easy straightforward video

  • @tamaskiri1849
    @tamaskiri1849 Год назад

    Thank you man! I search that thing like several weeks, and your video helped me

    • @DA-LAB
      @DA-LAB  Год назад

      Glad I could help :)

  • @FitKlik
    @FitKlik Год назад

    One of the best tutorials I've seen! Thanks a lot!

  • @Samatizer
    @Samatizer 2 года назад

    This is one of the best tutorials out here! Thanks sooo much

    • @DA-LAB
      @DA-LAB  2 года назад

      Glad it was helpful!

  • @fatpenguin_
    @fatpenguin_ Год назад +1

    Thank you so much! This tutorial helped me a lot and now I added a sprint mechanics to my game! Easy and quick tutorial! :D

  • @NayyarAbbas-sh1vw
    @NayyarAbbas-sh1vw 2 года назад +2

    We need more people like him, legend.

    • @DA-LAB
      @DA-LAB  2 года назад

      Thanks :)

  • @qwe-de7xd
    @qwe-de7xd Год назад +6

    I get this error message when calling the function:
    NullReferenceException: Object reference not set to an instance of an object
    There are no red lines in vs and the game runs without problem until I try to call the function.

    • @cookie856
      @cookie856 Год назад +1

      You may have forgotten the tag or badly written it

    • @qwe-de7xd
      @qwe-de7xd Год назад +2

      @@cookie856 If i remember correctly i was trying to find a clone that hadn't spawned yet. Thanks for the help though 😀

    • @boombox8408
      @boombox8408 Год назад

      I also have this problem

  • @kingdoom1906
    @kingdoom1906 2 года назад +1

    thank you man i was just thinking how i can call it from prefab
    thank you very helpful

    • @DA-LAB
      @DA-LAB  2 года назад

      My pleasure, thanks for your support :)

  • @sneezerplays
    @sneezerplays Год назад

    You made so simple, God Bless you Bro🙏

    • @DA-LAB
      @DA-LAB  Год назад

      Glad it helped :)

  • @MegaXDBrasil
    @MegaXDBrasil Год назад +5

    Instance of Object error

  • @xisu8167
    @xisu8167 Год назад +4

    when you naming everything needed, do you know it's really hard to distinguish which is calling which???

    • @DA-LAB
      @DA-LAB  Год назад +1

      Fair point :)

  • @zackwilder1856
    @zackwilder1856 Год назад

    Finally!!! Simple and working! Thanx!

    • @DA-LAB
      @DA-LAB  Год назад

      Glad it helped :)

  • @xVemist
    @xVemist 4 месяца назад

    2 years ago and it helped me figure out a solution for an object i instantiate on a respawn point, but i can't assign it a respawn object because it is a prefab. I always wanted to know if I could call scripts from other scripts without unity events. TY

  • @majaharkazi2030
    @majaharkazi2030 Год назад +3

    NullReferenceException: Object reference not set to an instance of an object ,
    why am I getting this error ?

    • @WallerMentality
      @WallerMentality 3 месяца назад

      Did you attach it to an empty object? It's basically telling you that the script has no object to reference in order to get the functions from the script

  • @NNether23
    @NNether23 Год назад

    finaly a good tutorailn

  • @darthbigboy7978
    @darthbigboy7978 4 месяца назад

    This is the best

  • @RidwanChachunya
    @RidwanChachunya Год назад

    Thank u its help me a lot

    • @DA-LAB
      @DA-LAB  Год назад

      Glad to hear that :)

  • @prklp69
    @prklp69 10 месяцев назад

    what if i want to call a funtion from 2 different gameobjects with the same script

  • @64mxg
    @64mxg Год назад

    Gracias, me funciono muy bien!!!!

  • @gusmangusman1405
    @gusmangusman1405 2 года назад +1

    thankyou bro

    • @DA-LAB
      @DA-LAB  2 года назад

      Happy to help :)

  • @Kapfz
    @Kapfz 9 месяцев назад

    This is very confusing with every part being called "needed" you colud have atleast named them needed1, needed2, ... to make it more obvious what part you mean

  • @WillToWinvlog
    @WillToWinvlog Год назад

    As nice as this is, I am using tags for something else. How can you do this without the tags?

  • @scarshe5978
    @scarshe5978 2 года назад +3

    not sure what version your using but this works for me in 2021.3.6f1
    public GameObject ScoobyDoo -> link your desired GameObject with the new variable ScoobyDoo in the unity inspector
    public void MyFunctionThatIsGoingToActivateADifferentFunction( )
    {
    ScoobyDoo . GetComponent ( ) . NameOfFunctionThatNeedsToBeActivatedGoesHere ( ) ;
    }
    way more simple and you dont need tags or anything

    • @DA-LAB
      @DA-LAB  2 года назад +1

      Thanks, that would work too.

    • @romeprince11
      @romeprince11 2 года назад

      nope, does not work
      The only method that works is the one Da Lab shows in this video
      Linking a GameObject doesn't work, just tested

    • @scarshe5978
      @scarshe5978 2 года назад

      @@romeprince11 worked for me, thats why i wrote it here

    • @DA-LAB
      @DA-LAB  2 года назад

      Thanks for the feedback @romeprice11. Let me try @scarshe5978 suggestion and will let you know how it goes.