GDScript Callables & Lambdas Deep Dive | Godot 4 Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 พ.ย. 2024

ความคิดเห็น • 75

  • @sixtimesnine9170
    @sixtimesnine9170 ปีที่แล้ว +40

    There’s a lot of poorly presented Godot tutorials around - too fast, too slow, not enough explanation, too much explanation, too short, or just way too long. This is none of those things, it’s a Goldilocks tutorial, it’s just right. Thank you, keep it up.

    • @sujimayne
      @sujimayne 5 หลายเดือนก่อน +1

      Most of the Godot tutorials are hacky and crappy code. Just outright terrible practices.

  • @_I-OvO-I_
    @_I-OvO-I_ 5 หลายเดือนก่อน +5

    Why can't more tutorials be like this? Clears up any confusion I had before.

  • @stedunn563
    @stedunn563 2 หลายเดือนก่อน +1

    This is frustrating, as someone who makes tutorials on my other channel, non are this good!! Your examples and explanations work so well with my learning style. Thanks man!

  • @willd2609
    @willd2609 5 หลายเดือนก่อน +1

    this is weirdly one of the most useful tutorials I've seen on Godot yet. Would love to see you explain more of the most commonly useful GDScript things at this same level. Thank you!!!

  • @jiro4559
    @jiro4559 หลายเดือนก่อน

    The practical example is the key. It makes everything so much clearer. Without it, it's a bit abstract for a beginner. Good one, mate!

  • @Mintarcade
    @Mintarcade ปีที่แล้ว +22

    I'm really liking your teaching style! Keep doing more of these deep dives on the Godot engine, please!

    • @Blargis3d
      @Blargis3d  ปีที่แล้ว +4

      Thank you so much! I definitely will! Are there any topics in particular that you would like to learn more about?

    • @Mintarcade
      @Mintarcade ปีที่แล้ว +2

      @@Blargis3d I appreciate how you recreated the InvokeRepeating function from Unity. I'm curious about other useful Unity functions that can be recreated using Godot 4 concepts. I believe this topic would be interesting to many Unity expats who are accustomed to certain features they are comfortable with, but find themselves lacking out-of-the-box functionalities like interfaces, event delegates, and so on.

    • @Blargis3d
      @Blargis3d  ปีที่แล้ว +3

      That is a great point, I've been thinking it would be cool to make a video like this. I will look into it!

  • @Korn1holio
    @Korn1holio 8 หลายเดือนก่อน +1

    Super useful video. You explain everything so thoroughly, and yet so dynamically that I rewatched it twice and never felt bored. Amazing teacher!

  • @Distortion0
    @Distortion0 7 หลายเดือนก่อน +2

    I'm a non-game programmer trying to learn godot and this helped so much.

  • @pab_loq
    @pab_loq ปีที่แล้ว +2

    This is super usefull, i would like more! this is the king of tutorial that helps, not that "do this", but "understand this and apply yourself", thank you!

  • @danacosta5237
    @danacosta5237 9 หลายเดือนก่อน +2

    god damn this was such a clear and concise tutorial, just subscribed thank you!

  • @theyellowarchitect4504
    @theyellowarchitect4504 ปีที่แล้ว +3

    I am grateful for this tutorial. That util function is required for any serious game, and its as clean as it gets. That array mapping via callable got me surprised as I was like "Why obscure when you can do foreach array element loop and call your function" then it got to the filter part.

  • @3db-
    @3db- ปีที่แล้ว +6

    This was a fantastic video. Super useful and probably the best intermediate/advanced GDScript content I've seen.
    I see you haven't made another deep dive in a while, but really hoping you do. I'd pay for more content like this. I had no idea GDScript was functional like JavaScript with first-class functions and lamda functions.
    I'd love to see more videos about GDScript, perhaps how first-class functions can be used even further like you demonstrated with the InvokeRepeating utility. How those array functions like map and filter can be used in the context of game development as well.
    Please make more videos like this!

  • @intevolver
    @intevolver ปีที่แล้ว +1

    From zero to understanding, great tutorial.

  • @edeciotheghost1637
    @edeciotheghost1637 6 หลายเดือนก่อน

    Im 3 days into programming, and this even made sense to me. Very well put together tutorial. You've got a new sub

  • @Sylfa
    @Sylfa 2 หลายเดือนก่อน +1

    One thing to note, you can still name your lambda function. It helps if the lambda function has an error in it, such as trying to call a function on a null object, because then the debugger shows the name of the lambda function instead of .

  • @makadi86
    @makadi86 ปีที่แล้ว +1

    your teaching steps is professional

  • @jerryzhao666
    @jerryzhao666 6 หลายเดือนก่อน

    Thank you for enlightening me about the concept of Callable, which I never quite understood before, it must come in handy.

  • @SodaImpact
    @SodaImpact ปีที่แล้ว +1

    Cristal clear explainations, thank you so much ! I'd love to see more.

  • @WintercloudGames
    @WintercloudGames 10 หลายเดือนก่อน +1

    Saving this for later 😊

  • @sonny5497
    @sonny5497 ปีที่แล้ว

    You are an excellent teacher. I haven't seen godot video explained with such clarity yet. Thanks for making these man! Hope you continue making such videos. Liked and subbed.

    • @Blargis3d
      @Blargis3d  ปีที่แล้ว

      That’s really nice of you to say, thank you!

  • @evilferber2704
    @evilferber2704 ปีที่แล้ว +1

    "Static" confused me :D But everyting else is sooo cleeear with your explanations, thank you so much for being such a nice person and share this kind of knowledge. I am waiting for more!

    • @Blargis3d
      @Blargis3d  ปีที่แล้ว +6

      I'm so happy you found it helpful!!
      As for "Static", this topic can be a little confusing when you're first learning so I totally understand. I hopefully will have a video on this soon!
      In the meantime, here is a brief explanation:
      In the video, I declared the static method in my "Util" class. So normally to call a method in a class, you need to create an instance of that class, for example:
      var my_util_instance = Util.new()
      my_util_instance.run_periodically(parent, function, period)
      But because I declared "run_periodically" as "static", I am saying that this method applies to the Util "type" as a whole, not just instances of the Util type. In other words, I am telling Godot that I don't need to create an instance of Util to be able to call "run_periodically(...)". So since the method is static, we can just say
      Util.run_periodically(parent, function, period)
      This is cleaner and also saves memory because now we're not creating new objects if we don't have to.
      The main restriction with using "static" methods is that they can't rely on any data that would normally be tied to an instance of that class. So for example, for the class Vector3, we can create an instance of a Vector3, then get its length by calling "instance.length()" like this:
      var my_vector = Vector3(5, 2, 6)
      var length = my_vector.length()
      The method "length" is a non-static method. It can't be static because it needs data specific to instances of Vector3. For example, it makes no sense to do:
      var length = Vector3.length()
      What would this even return? We don't have an instance of a Vector3 yet so there is nothing to calculate. Because this makes no sense, the "length()" method is a non-static method and if you try to do the above it will just cause an error saying 'Cannot call non-static function "length()" on the class "Vector3" directly. Make an instance instead.`
      Hope that helps! If it's still a bit unclear, I should have a video on this soon!

    • @evilferber2704
      @evilferber2704 ปีที่แล้ว

      @@Blargis3d It is clear AF to me :D Thank you once again!

  • @Deribaldo
    @Deribaldo 7 หลายเดือนก่อน

    I love the way you explain things. Thanks for the tutorial

  • @jasenlakic5033
    @jasenlakic5033 11 หลายเดือนก่อน

    Thanks you, this was a great one. Also showing practical examples at the end is quite valuable

  • @nathnolt
    @nathnolt ปีที่แล้ว +5

    You know, you could have made it simpler by using bind. With bind, you can preset arguments. Whenever a callable is called, all of it's potential arguments get passed in before bind, so in your examples: you could have used
    print(get_function_runtime(count_to_number.bind(10_000)).
    where calling bind returns a new function, which has it's last x arguments bounded to the parameters passed in by bind. This is especially useful for signals, where you have to pass in some kind of data, based upon an instance of something.

    • @Blargis3d
      @Blargis3d  ปีที่แล้ว

      Good point, this is definitely valid and a great way to do it if it meshes with your brain.
      I remember learning JavaScript bind() syntax many years ago when I was learning the React web dev framework, and it made absolutely no sense to my noob-coder brain.
      In my opinion the way I showed is a bit easier for a beginner to reason about, which is why I didn’t even mention bind() syntax. I’d certainly be curious to know if you or others think otherwise though

    • @nathnolt
      @nathnolt ปีที่แล้ว +1

      @@Blargis3d I personally don't think that bind is too complicated. Because it's basically like instead of passing in a function, you're assigning some data to it as well, It's just that this data can be accessed as the nth argument. In most cases, you're not going to pass in data with the function call as well, so this data will be the first argument.
      But even if you do, that's only 1 more little complexity thing, which you could teach later.

  • @suthamonhengrasmee8182
    @suthamonhengrasmee8182 11 หลายเดือนก่อน +1

    Thank you, this is very useful!

    • @Blargis3d
      @Blargis3d  11 หลายเดือนก่อน

      Glad it was helpful!

  • @albert69Einstein
    @albert69Einstein 7 หลายเดือนก่อน

    wow!!! ty !!! even with coffee this was alot to absorb. but I think I finally got it straight in my head.
    now I just need to apply this in a few practice code sessions and I will be good to go.

  • @Moj206Pejo
    @Moj206Pejo ปีที่แล้ว

    You are a wonderful teacher, please post more tutorials, I love you and support you with all my heart.♥♥♥

    • @Blargis3d
      @Blargis3d  ปีที่แล้ว +1

      I’m glad you liked it, thank you for the kind words! ❤️

  • @dueddel
    @dueddel ปีที่แล้ว +4

    You just made me subscribe. I like the way of presenting and explaining. Very understandable, very clear, very good, very thank you. 😘👍

  • @reigndevelops5797
    @reigndevelops5797 7 หลายเดือนก่อน

    Thanks! Your tutorial is awesome (and a gold mine!) not sure why my algorithm dont suggest them.

  • @-lunte.
    @-lunte. ปีที่แล้ว

    freakin awesome man. exactly what i was looking for!

  • @Macronaught
    @Macronaught ปีที่แล้ว

    Thanks for making this tutorial! I got so much out of it!

  • @sheepcommander_
    @sheepcommander_ ปีที่แล้ว

    i FINALLY understand lambdas lol, after I've 100%'d AP CS A, the AP Test, and the Harvard cs50 course

  • @arcade_mntra
    @arcade_mntra ปีที่แล้ว

    This video was super helpful. Thanks a ton man!

  • @YouTubsel
    @YouTubsel ปีที่แล้ว

    Liked the dep dive. Want more deep dives. Liked. subscribed. 😄

  • @zeeebyuwu9546
    @zeeebyuwu9546 6 หลายเดือนก่อน

    thank you! this has been very helpful

  • @shoggoth
    @shoggoth 8 หลายเดือนก่อน +2

    > Deep dive
    > No mention of bind()

  • @SheepUndefined
    @SheepUndefined 8 หลายเดือนก่อน

    You could also technically test the greeting function by having its argument be person:="jim"
    that way there's a default value, and you can call it without any arguments.

  • @onlineflowerstore
    @onlineflowerstore ปีที่แล้ว

    very good explanation, thank you!

  • @ghjghjghkimo
    @ghjghjghkimo ปีที่แล้ว

    很好的教學影片! 讓我學到很多~

  • @ianhall7513
    @ianhall7513 ปีที่แล้ว +1

    y'know, I *would* like to see more about static functions...
    also how dot products work. Like I know they can be used to compare angles, so I want to experiment using dot products to determine whether a character is facing perpendicular to a wall or parallel to it. That way a character can either do a wall run or slide down the wall and do a wall jump based on character orientation instead of using button combinations.
    Jeez, I could make quite the list of things I want to know more about... I started coding 3 weeks ago, so I have a long road ahead lol.
    This helped me figure out why i couldn't successfully use get_wall/floor_normal (I forgot the parenthesis... lol ) I'm trying to figure out how I can use surface normals to detect ramps so I can adjust momentum based on angle. more weight makes climbing and stopping harder emphasized by angle of descent/ascent.
    One thing I'd really like to find out is if meshes can be drawn curved using the surface tool. I'm doing a voxel-style game, but I want to bevel the edges to give it a softer feel without increasing the number of vertices. might be impossible, idk yet.

  • @flowmatic98
    @flowmatic98 7 หลายเดือนก่อน

    Hey loved the video! Could you explain what add_child(timer) is doing exactly. You said it adds it to the tree, I’m guessing you mean the node tree but I don’t understand why you have to do that. I appreciate any response :)

  • @ianlardo1959
    @ianlardo1959 10 หลายเดือนก่อน

    you are my hero

  • @DavidPrenticeJr
    @DavidPrenticeJr ปีที่แล้ว

    Great tutorial thank you!

  • @ArabGameDev
    @ArabGameDev ปีที่แล้ว +1

    thanks
    make a video about static vars and functions

  • @CryingOrc
    @CryingOrc ปีที่แล้ว

    It is really cool.

  • @fvhaudsilhvdfs
    @fvhaudsilhvdfs 8 หลายเดือนก่อน

    son of a bitch this is the clearest godot tutorial i've ever watched

  • @플래이브이카티tv구독
    @플래이브이카티tv구독 2 หลายเดือนก่อน

    thank you!!

  • @VaSoapman
    @VaSoapman ปีที่แล้ว

    Hello Blargis!
    Hello Blargis!

  • @cq7743
    @cq7743 ปีที่แล้ว +1

    Hello author, thank you for your video creation. It's very friendly to me as a beginner. In my country, there are very few video tutorials about Godot. Can I share your video on domestic websites, including your link and creative information? Looking forward to your reply. Thank you

    • @Blargis3d
      @Blargis3d  ปีที่แล้ว

      Sure! I appreciate the share!

  • @meraklmuskulpesent8313
    @meraklmuskulpesent8313 ปีที่แล้ว

    Thanks!

  • @stefansava
    @stefansava 5 หลายเดือนก่อน

    MOAR

  • @tigeruppercut2000
    @tigeruppercut2000 ปีที่แล้ว

    Hmmm like function pointers I guess?

  • @m.a.t.a.s
    @m.a.t.a.s 4 หลายเดือนก่อน

    Wait, technically function.call is also a callable.
    So that means you can do:
    var x = function.call
    x.call()
    which basically means no one's stopping you from doing function.call.call.call.call.call.call.call.call.call.call.call.call.call.call.call.call.call.call.call.call.call.call.call.call()

  • @JacobKinsley
    @JacobKinsley ปีที่แล้ว

    You know, it's only just occurred to me that the word Godot is really weird. How is it pronounced? Does it rhyme with Robot? It would make sense because the logo is a robot. Is it good-oh? Because Americans say it like that. Personally I always call it "God O"

    • @VaSoapman
      @VaSoapman ปีที่แล้ว +1

      I think the word is french or is based off of some french movie named Godot.
      Because of its french roots I think that is why the T is silent.
      In the movie a bunch of guys were waiting around for something that never came.
      The first devs felt like that about game engines and so they made their own.

    • @JacobKinsley
      @JacobKinsley ปีที่แล้ว

      @@VaSoapman I know about waiting on godot but I still don't know why the logo is a robot if it isn't pronounced like robot, and why it's "gud-oh" and not "god-oh"

    • @danielphil4976
      @danielphil4976 ปีที่แล้ว +1

      ​@@JacobKinsleythe Devs said to pronounce it however you like.

    • @JacobKinsley
      @JacobKinsley ปีที่แล้ว +1

      @@danielphil4976 I'll pronounce it "godot" (it's pronounced "godot", but spelled as "godot")

  • @ensarija
    @ensarija 2 หลายเดือนก่อน +1

    9:40 we could make profiling function with 2 arguments, one for callable, another for it's arguments... But yeah..

  • @nguyennhat5769
    @nguyennhat5769 ปีที่แล้ว

    Thank you, like n sub