GDScript Callables & Lambdas Deep Dive | Godot 4 Tutorial

  Рет қаралды 12,996

Blargis

Blargis

Жыл бұрын

In this in depth Godot 4 GDScript tutorial I'll thoroughly explain:
- GDScript Callables (AKA first class functions)
- Lambda functions (AKA anonymous functions)
- Practical scenarios for using both callables and lambdas (including how this all relates to signals and array functions such as map() and filter()).
#godot #godotengine #gdscript

Пікірлер: 70
@sixtimesnine9170
@sixtimesnine9170 8 ай бұрын
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 Ай бұрын
Most of the Godot tutorials are hacky and crappy code. Just outright terrible practices.
@_I-OvO-I_
@_I-OvO-I_ 22 күн бұрын
Why can't more tutorials be like this? Clears up any confusion I had before.
@Distortion0
@Distortion0 2 ай бұрын
I'm a non-game programmer trying to learn godot and this helped so much.
@Mintarcade
@Mintarcade Жыл бұрын
I'm really liking your teaching style! Keep doing more of these deep dives on the Godot engine, please!
@Blargis3d
@Blargis3d Жыл бұрын
Thank you so much! I definitely will! Are there any topics in particular that you would like to learn more about?
@Mintarcade
@Mintarcade Жыл бұрын
@@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 Жыл бұрын
That is a great point, I've been thinking it would be cool to make a video like this. I will look into it!
@SodaImpact
@SodaImpact 11 ай бұрын
Cristal clear explainations, thank you so much ! I'd love to see more.
@Pabloquerock
@Pabloquerock 11 ай бұрын
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!
@3db-
@3db- 10 ай бұрын
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!
@Korn1holio
@Korn1holio 4 ай бұрын
Super useful video. You explain everything so thoroughly, and yet so dynamically that I rewatched it twice and never felt bored. Amazing teacher!
@Deribaldo
@Deribaldo 2 ай бұрын
I love the way you explain things. Thanks for the tutorial
@theyellowarchitect4504
@theyellowarchitect4504 11 ай бұрын
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.
@edeciotheghost1637
@edeciotheghost1637 Ай бұрын
Im 3 days into programming, and this even made sense to me. Very well put together tutorial. You've got a new sub
@willd2609
@willd2609 Ай бұрын
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!!!
@makadi86
@makadi86 Жыл бұрын
your teaching steps is professional
@ahmedsan4065
@ahmedsan4065 4 ай бұрын
Love the detailed examples, keep em coming, subscribed!
@jerryzhao666
@jerryzhao666 Ай бұрын
Thank you for enlightening me about the concept of Callable, which I never quite understood before, it must come in handy.
@danacosta5237
@danacosta5237 4 ай бұрын
god damn this was such a clear and concise tutorial, just subscribed thank you!
@intevolver
@intevolver 11 ай бұрын
From zero to understanding, great tutorial.
@jasenlakic5033
@jasenlakic5033 7 ай бұрын
Thanks you, this was a great one. Also showing practical examples at the end is quite valuable
@sonny5497
@sonny5497 8 ай бұрын
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 8 ай бұрын
That’s really nice of you to say, thank you!
@albert69Einstein
@albert69Einstein 2 ай бұрын
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.
@Macronaught
@Macronaught 9 ай бұрын
Thanks for making this tutorial! I got so much out of it!
@nathnolt
@nathnolt 8 ай бұрын
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 8 ай бұрын
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 8 ай бұрын
@@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.
@zeeebyuwu9546
@zeeebyuwu9546 Ай бұрын
thank you! this has been very helpful
@ghjghjghkimo
@ghjghjghkimo 9 ай бұрын
很好的教學影片! 讓我學到很多~
@-lunte.
@-lunte. 9 ай бұрын
freakin awesome man. exactly what i was looking for!
@WintercloudGames
@WintercloudGames 6 ай бұрын
Saving this for later 😊
@arcade_mntra
@arcade_mntra 10 ай бұрын
This video was super helpful. Thanks a ton man!
@Moj206Pejo
@Moj206Pejo 9 ай бұрын
You are a wonderful teacher, please post more tutorials, I love you and support you with all my heart.♥♥♥
@Blargis3d
@Blargis3d 9 ай бұрын
I’m glad you liked it, thank you for the kind words! ❤️
@onlineflowerstore
@onlineflowerstore Жыл бұрын
very good explanation, thank you!
@suthamonhengrasmee8182
@suthamonhengrasmee8182 6 ай бұрын
Thank you, this is very useful!
@Blargis3d
@Blargis3d 6 ай бұрын
Glad it was helpful!
@reigndevelops5797
@reigndevelops5797 2 ай бұрын
Thanks! Your tutorial is awesome (and a gold mine!) not sure why my algorithm dont suggest them.
@DavidPrenticeJr
@DavidPrenticeJr 10 ай бұрын
Great tutorial thank you!
@dueddel
@dueddel Жыл бұрын
You just made me subscribe. I like the way of presenting and explaining. Very understandable, very clear, very good, very thank you. 😘👍
@SnowyFoxFox
@SnowyFoxFox Жыл бұрын
Seconded.
@YouTubsel
@YouTubsel 10 ай бұрын
Liked the dep dive. Want more deep dives. Liked. subscribed. 😄
@ianlardo1959
@ianlardo1959 5 ай бұрын
you are my hero
@CryingOrc
@CryingOrc 11 ай бұрын
It is really cool.
@evilferber2704
@evilferber2704 Жыл бұрын
"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 Жыл бұрын
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!
@SheepUndefined
@SheepUndefined 3 ай бұрын
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.
@meraklmuskulpesent8313
@meraklmuskulpesent8313 11 ай бұрын
Thanks!
@sheepcommander_
@sheepcommander_ 8 ай бұрын
i FINALLY understand lambdas lol, after I've 100%'d AP CS A, the AP Test, and the Harvard cs50 course
@ianhall7513
@ianhall7513 Жыл бұрын
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.
@ArabGameDev
@ArabGameDev Жыл бұрын
thanks make a video about static vars and functions
@fvhaudsilhvdfs
@fvhaudsilhvdfs 3 ай бұрын
son of a bitch this is the clearest godot tutorial i've ever watched
@stefansava
@stefansava 19 күн бұрын
MOAR
@flowmatic98
@flowmatic98 2 ай бұрын
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 :)
@VaSoapman
@VaSoapman 11 ай бұрын
Hello Blargis! Hello Blargis!
@shoggoth
@shoggoth 4 ай бұрын
> Deep dive > No mention of bind()
@cq7743
@cq7743 Жыл бұрын
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!
@tigeruppercut2000
@tigeruppercut2000 Жыл бұрын
Hmmm like function pointers I guess?
@Blargis3d
@Blargis3d Жыл бұрын
Yes!
@JacobKinsley
@JacobKinsley 11 ай бұрын
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 11 ай бұрын
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 11 ай бұрын
@@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 10 ай бұрын
​@@JacobKinsleythe Devs said to pronounce it however you like.
@JacobKinsley
@JacobKinsley 10 ай бұрын
@@danielphil4976 I'll pronounce it "godot" (it's pronounced "godot", but spelled as "godot")
@nguyennhat5769
@nguyennhat5769 8 ай бұрын
Thank you, like n sub
Optimizing my Game so it Runs on a Potato
19:02
Blargis
Рет қаралды 467 М.
WHY IS THE STACK SO FAST?
13:46
Core Dumped
Рет қаралды 140 М.
THE POLICE TAKES ME! feat @PANDAGIRLOFFICIAL #shorts
00:31
PANDA BOI
Рет қаралды 24 МЛН
Alat Seru Penolong untuk Mimpi Indah Bayi!
00:31
Let's GLOW! Indonesian
Рет қаралды 15 МЛН
1❤️
00:17
Nonomen ノノメン
Рет қаралды 13 МЛН
NERF WAR HEAVY: Drone Battle!
00:30
MacDannyGun
Рет қаралды 50 МЛН
8 TypeScript Tips To Expand Your Mind (and improve your code)
10:54
Dear Functional Bros
16:50
CodeAesthetic
Рет қаралды 473 М.
Using docker in unusual ways
12:58
Dreams of Code
Рет қаралды 412 М.
Why Most Programmers DON'T Last
18:56
Thriving Technologist
Рет қаралды 272 М.
The Formula for Replayable Games
18:44
Blargis
Рет қаралды 216 М.
Faster than Rust and C++: the PERFECT hash table
33:52
strager
Рет қаралды 521 М.
Stop Recommending Clean Code
27:05
ThePrimeTime
Рет қаралды 452 М.
How to program in Godot - GDScript Tutorial
58:10
Brackeys
Рет қаралды 439 М.
C++ vs Rust: which is faster?
21:15
fasterthanlime
Рет қаралды 380 М.
THE POLICE TAKES ME! feat @PANDAGIRLOFFICIAL #shorts
00:31
PANDA BOI
Рет қаралды 24 МЛН