Corrections: 33:35 - I was using the old approach to signals, it's now possible to use signals without strings at all: signal signal_name signal_name.connect(function_name) signal_name.emit() If you want to send arguments along, you can bind them to the function when connecting or emit them as comma separated list: signal_name.connect(function_name.bind(23423,"AAAAA")) signal_name.emit(23423,"AAAAA") At 9:44, I said "strong typing," but should have said "static typing." Godot is dynamic, with the ability to be static. Let me know if I missed anything else!
Was about to comment the same thing! That's something I'm still a victim of trying to use strings all the time for signals and then remembering i don't need to anymore. Point being, no worries! It be like that.
To elaborate further, GDScript is a _dynamically typed_ language with support for optional static type checking, compiler optimizations and helpful editor features based on type hints. This kind of optional static typing is known as "gradual typing." I believe the most famous gradually typed language is currently TypeScript. The feature where you can assign a variable using := and it gets a static type is a form of type inference. It can be tricky, however. An expression like 100/3 will result in a int type, but 100.0/3 will instead result in a float. It's best to be explicit. Another good reason to use type hints in GDScript is that the editor will suggest the right properties, methods and signals for the type, so you don't have to remember or look things up as much when writing code. You can also declare the return type of your functions so that when you write, say, "compute_2d_speed()." the editor will know the return type is a Vector2 and (after you type the period) it will suggest the right stuff for that type, thanks to the function being declared as returning a type Vector2. A fully typed function declaration goes like this: func do_thing(foo: int, bar: float) -> Vector2:" You can use the type system with your own classes as types. Check out "Static typing in GDScript" in the Godot docs. Edit: it dawned on me that my use of the term "type annotation" may be confusing given that there's an unrelated GDScript feature simply called annotations, which start with an @ character. I've changed it to the term used in the documentation: type hints
amazing vid, there's a huge lack of tutorials out there that go through fundamentals that are geared towards explaining how godot actually does things for serious developers instead of just recipes for game clones and overviews that are little more than lists
Happy I found this channel. A competent programmer walking me through items in Godot's class reference document is refreshing. (no distractions, just information)
NodePath can also refer to indexed properties of an Object, for example on a Node: ^"NodeName:name" will refer to NodeName's name property. what's more, you can do sub-indexing, for example, ^"Node2D:position:x" will refer to Node2D's position vector's x property. Object has methods to get and set properties by indexed NodePaths (get/set_indexed), which can be useful in very dynamic scenarios.
Around 9:44, the proper terms are "static typing" and "dynamic typing". [edit: same about other uses of the terms] "Weak" and "strong" typing refer to something else. If anyone's curious, static vs dynamic refers to variables (and parameters) being able to change the type they refer to. Weak and strong typing refers to how operations work on the types of values (values, as opposed to variables). If for example, you can add two characters as if they were numbers, then that's weak typing. You can have that in statically typed languages (like C, static and weak), but you can't in many strongly typed dynamic languages (Scheme, Python, and a long etc). And then, there are languages like assemblers or Forth, in which you don't have a lot of type information, so they are kinda like weak and dynamic in a sense, but they're usually called typeless. PS: finished the video, and learned some nice stuff, ty, great video :)
Thank you very much for this. I love your pace and I've really enjoyed the 'you' in your dialogue, you have a voice that makes the learning more conversational than instructional imo. Cheers
16:33 The best way to make a strongly typed Dictionary is to make and export your own class in another Godot script that can then be imported anywhere.
This is an amazing tutorial to understand the basics of coding in Godot, so thank you very much for that! I am reaching a stage where I needed to know more about all those you are covering in order to properly understand how they work, and sometimes I found myself with a lack of resources to actually check information about some of those...which you mention here! Great way to start the week, indeed! Thanks a lot for that!
I used to worry about the limitation of the size of a variable. It turns out, there is literally nothing to worry about because the size is so massive that you will never need a number smaller or larger than this for real-world applications. There are, of course, edge case's but there are solutions already written for these.
Thats a great vid not only for godot newbies but programming newbies in general. One note tho, you didnt really explain why var without a strong type can be an integer AND string. For me its not a problem but it might confuse someone who is new to this sort of things
One thing I had to use packed bytes for was reading the raw bytes of a file, the format of which was custom and I had to write a custom interpreter for it, doing an xor on each field depending on how big the field was. After reading each entry, I just stored them as part of a custom node type using the regular variant types (int, String, float, etc), but I didn't know doing that makes them take up 20 bytes. That's... interesting...
For packed strings, my guess is that Godot doesn't store something like Array[String], but rather Array[*String], as in each element in the packed string array is just a pointer to the string. This way, you can still have the "access by index using size(type) * index", type being the address (int64 I guess?)
That would make sense. It would add a dereference step to each access, but that sounds a lot more sane than trying to calculate the location of elements in an uneven array. I should check the actual source code, I wonder if the strings are packed into a single C-string or similar to make copying the entire array faster. 🤔 You'd still need a pointer to find the start of each string, but everything would be a single block, which is an important part of packed arrays in general.
11:54 omfg "i" as integer... not imaginary when i hear "vector", i immediately thing math. so when there is an unknown "i", yeah its obviously imaginary numbers. so i was thinking that those vectors were adding another dimention to the regular depicted number but the right answer is so much simpler...
Good video, go thru many complex stuff and many "rocks" you can hit in Godot. Small note about Color - it is SRGB converted - so do not use Color type to store/send vec3 to shaders - this will lead to very confusing bugs. 19:00 yep performance xD 27:04 seconds xD GDScript not that slow, ye on screen correction xD 38:18 Transform in confusing especially when you do dynamic UI-stuff - everything updates on resize - handling resize of elements in UI correctly is annoying in Godot.
Hi SDG Games ! If I may, can I ask you why are Int, Float, Bool, Vector2, etc are call ''variant'' and not ''type''. I though that float and int would be variable type, a type of variable. I understand that variable type can ''vary'' from one type to another (hence the variant name ?), but why does variable type are called variant then ? Thx a lot for you very interesting video :-)
That's a good question! Unfortunately, definitions get a bit fuzzy between languages, so I just tried to stick with what the docs said. Variants are a universal container that can hold/become any "type". Typically, a language would have multiple primitive types. So, C has int8, uint16, bool, etc. These are like the letters in an alphabet. But Godot only has one type: the variant. So, instead of the alphabet looking like ABCDE..., it's ÀÁÃĂẶ... There are still a lot of different "types," and practically, it's still an alphabet, but there is a commonly reused component in everything. In C, "bool" doesn't inherit anything, it is the most basic definition of "true or false Boolean type." In Godot, "bool" is a 20 byte container (Variant) that happens to contain a true or false value at the current time. In C, you can't change a bool into an int, you have to throw the variable out and get a new one, But in Godot, you can, since everything is a variant anyways.
If you found that impressive, make sure you learn about Scene Unique Nodes 😉 Ah... the joy of moving your nodes around the scene tree willy nilly without constantly fixing up node paths!
@@sheepcommander_ The editor auto completes unique names, and if you drag & drop a scene unique node into the editor, it'll reference it using %NodeName instead of a path.
Corrections:
33:35 - I was using the old approach to signals, it's now possible to use signals without strings at all:
signal signal_name
signal_name.connect(function_name)
signal_name.emit()
If you want to send arguments along, you can bind them to the function when connecting or emit them as comma separated list:
signal_name.connect(function_name.bind(23423,"AAAAA"))
signal_name.emit(23423,"AAAAA")
At 9:44, I said "strong typing," but should have said "static typing." Godot is dynamic, with the ability to be static.
Let me know if I missed anything else!
Was about to comment the same thing! That's something I'm still a victim of trying to use strings all the time for signals and then remembering i don't need to anymore.
Point being, no worries! It be like that.
To elaborate further, GDScript is a _dynamically typed_ language with support for optional static type checking, compiler optimizations and helpful editor features based on type hints.
This kind of optional static typing is known as "gradual typing." I believe the most famous gradually typed language is currently TypeScript.
The feature where you can assign a variable using := and it gets a static type is a form of type inference. It can be tricky, however. An expression like 100/3 will result in a int type, but 100.0/3 will instead result in a float. It's best to be explicit.
Another good reason to use type hints in GDScript is that the editor will suggest the right properties, methods and signals for the type, so you don't have to remember or look things up as much when writing code.
You can also declare the return type of your functions so that when you write, say, "compute_2d_speed()." the editor will know the return type is a Vector2 and (after you type the period) it will suggest the right stuff for that type, thanks to the function being declared as returning a type Vector2.
A fully typed function declaration goes like this: func do_thing(foo: int, bar: float) -> Vector2:"
You can use the type system with your own classes as types. Check out "Static typing in GDScript" in the Godot docs.
Edit: it dawned on me that my use of the term "type annotation" may be confusing given that there's an unrelated GDScript feature simply called annotations, which start with an @ character. I've changed it to the term used in the documentation: type hints
amazing vid, there's a huge lack of tutorials out there that go through fundamentals that are geared towards explaining how godot actually does things for serious developers instead of just recipes for game clones and overviews that are little more than lists
Happy I found this channel. A competent programmer walking me through items in Godot's class reference document is refreshing. (no distractions, just information)
NodePath can also refer to indexed properties of an Object, for example on a Node: ^"NodeName:name" will refer to NodeName's name property. what's more, you can do sub-indexing, for example, ^"Node2D:position:x" will refer to Node2D's position vector's x property. Object has methods to get and set properties by indexed NodePaths (get/set_indexed), which can be useful in very dynamic scenarios.
Around 9:44, the proper terms are "static typing" and "dynamic typing". [edit: same about other uses of the terms]
"Weak" and "strong" typing refer to something else.
If anyone's curious, static vs dynamic refers to variables (and parameters) being able to change the type they refer to.
Weak and strong typing refers to how operations work on the types of values (values, as opposed to variables). If for example, you can add two characters as if they were numbers, then that's weak typing. You can have that in statically typed languages (like C, static and weak), but you can't in many strongly typed dynamic languages (Scheme, Python, and a long etc).
And then, there are languages like assemblers or Forth, in which you don't have a lot of type information, so they are kinda like weak and dynamic in a sense, but they're usually called typeless.
PS: finished the video, and learned some nice stuff, ty, great video :)
Thanks, I added a correction.
Thank you very much for this. I love your pace and I've really enjoyed the 'you' in your dialogue, you have a voice that makes the learning more conversational than instructional imo. Cheers
Some useful and great stuff.....bring on more please.
Definitely!
16:33 The best way to make a strongly typed Dictionary is to make and export your own class in another Godot script that can then be imported anywhere.
This is an amazing tutorial to understand the basics of coding in Godot, so thank you very much for that! I am reaching a stage where I needed to know more about all those you are covering in order to properly understand how they work, and sometimes I found myself with a lack of resources to actually check information about some of those...which you mention here! Great way to start the week, indeed! Thanks a lot for that!
I've never seen an explanation of Quaternions that simple and clear. Thanks!
Do you tutor? My god it's so fun listening to you!
Amazing video, thank you so much for this!
This video is so useful!!
thankyouuu ! for making this video, this is very helpful
Please continue this series
this was so good, deserves more views
best
I used to worry about the limitation of the size of a variable. It turns out, there is literally nothing to worry about because the size is so massive that you will never need a number smaller or larger than this for real-world applications. There are, of course, edge case's but there are solutions already written for these.
I'm actually really excited for projections! I'd like to do more with cameras, screens and portals 😊
Thanks a lot for the video, I will be using NodePath a lot :)
Thats a great vid not only for godot newbies but programming newbies in general. One note tho, you didnt really explain why var without a strong type can be an integer AND string. For me its not a problem but it might confuse someone who is new to this sort of things
This video is insanely good
One thing I had to use packed bytes for was reading the raw bytes of a file, the format of which was custom and I had to write a custom interpreter for it, doing an xor on each field depending on how big the field was. After reading each entry, I just stored them as part of a custom node type using the regular variant types (int, String, float, etc), but I didn't know doing that makes them take up 20 bytes. That's... interesting...
That's a pretty cool use for it. Sorry for the bad news, that's a lot of wasted data. At least it's packed nicely on the disk :)
For packed strings, my guess is that Godot doesn't store something like Array[String], but rather Array[*String], as in each element in the packed string array is just a pointer to the string. This way, you can still have the "access by index using size(type) * index", type being the address (int64 I guess?)
That would make sense. It would add a dereference step to each access, but that sounds a lot more sane than trying to calculate the location of elements in an uneven array.
I should check the actual source code, I wonder if the strings are packed into a single C-string or similar to make copying the entire array faster. 🤔 You'd still need a pointer to find the start of each string, but everything would be a single block, which is an important part of packed arrays in general.
This is a great video, Thank you!!
11:54 omfg
"i" as integer... not imaginary
when i hear "vector", i immediately thing math. so when there is an unknown "i", yeah its obviously imaginary numbers. so i was thinking that those vectors were adding another dimention to the regular depicted number
but the right answer is so much simpler...
Good video, go thru many complex stuff and many "rocks" you can hit in Godot.
Small note about Color - it is SRGB converted - so do not use Color type to store/send vec3 to shaders - this will lead to very confusing bugs.
19:00 yep performance xD
27:04 seconds xD GDScript not that slow, ye on screen correction xD
38:18 Transform in confusing especially when you do dynamic UI-stuff - everything updates on resize - handling resize of elements in UI correctly is annoying in Godot.
Thanks for making such a useful series.
you best
Wow... Amazing tutorial bro... just wow. Instant sub from me 😊
Thanks! Glad it was helpful
Well done
thank youu
More reasons to procrastinate, exactly what I need.
Please make one where you cover all the class names like DirAccess and FileAccess in gdscript for godot 4.
big thanks.
1:17
yeah, i'm totally not procrastinating
Hi SDG Games ! If I may, can I ask you why are Int, Float, Bool, Vector2, etc are call ''variant'' and not ''type''. I though that float and int would be variable type, a type of variable. I understand that variable type can ''vary'' from one type to another (hence the variant name ?), but why does variable type are called variant then ? Thx a lot for you very interesting video :-)
That's a good question! Unfortunately, definitions get a bit fuzzy between languages, so I just tried to stick with what the docs said.
Variants are a universal container that can hold/become any "type".
Typically, a language would have multiple primitive types. So, C has int8, uint16, bool, etc. These are like the letters in an alphabet. But Godot only has one type: the variant.
So, instead of the alphabet looking like ABCDE..., it's ÀÁÃĂẶ... There are still a lot of different "types," and practically, it's still an alphabet, but there is a commonly reused component in everything.
In C, "bool" doesn't inherit anything, it is the most basic definition of "true or false Boolean type." In Godot, "bool" is a 20 byte container (Variant) that happens to contain a true or false value at the current time. In C, you can't change a bool into an int, you have to throw the variable out and get a new one, But in Godot, you can, since everything is a variant anyways.
Thx a lot ! That is answering my question brilliantly :-) @@SDGGames
I think the byte math was wrong
Huh, I didn't even know godot had the walrus operator.
wait you can put a carrot in front of a string and select nodes??? wtf woah
caret* lmfao
Yeah, it blew my mind a little. I don't think I've ever heard someone talk about that type.
If you found that impressive, make sure you learn about Scene Unique Nodes 😉
Ah... the joy of moving your nodes around the scene tree willy nilly without constantly fixing up node paths!
@@majorgnu you mean the percent sign? they're just okay, since it breaks if you rename it and last i checked they didn't seem to auto fill?
@@sheepcommander_ The editor auto completes unique names, and if you drag & drop a scene unique node into the editor, it'll reference it using %NodeName instead of a path.
Wait, I thought var means for variable
That's the question
Wtf your doing engineering XD 😂😅😊
@export_range🤯 thanks!