Every Variant in Godot 4

  Рет қаралды 8,910

SDG Games

SDG Games

Күн бұрын

Пікірлер: 58
@SDGGames
@SDGGames 9 ай бұрын
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!
@ExplodingImplosion
@ExplodingImplosion 9 ай бұрын
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.
@majorgnu
@majorgnu 9 ай бұрын
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
@amoraampersand
@amoraampersand 9 ай бұрын
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
@EfremZecarias
@EfremZecarias 9 ай бұрын
Happy I found this channel. A competent programmer walking me through items in Godot's class reference document is refreshing. (no distractions, just information)
@frechjo
@frechjo 9 ай бұрын
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 :)
@SDGGames
@SDGGames 9 ай бұрын
Thanks, I added a correction.
@paulmaguire872
@paulmaguire872 5 ай бұрын
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
@hermandarr6274
@hermandarr6274 9 ай бұрын
Some useful and great stuff.....bring on more please.
@SDGGames
@SDGGames 9 ай бұрын
Definitely!
@TheYagich
@TheYagich 9 ай бұрын
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.
@origenydestino13
@origenydestino13 5 ай бұрын
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!
@RedEyedJedi
@RedEyedJedi 7 ай бұрын
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.
@AliceAlexandra-d5t
@AliceAlexandra-d5t 9 ай бұрын
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.
@Ocdib
@Ocdib 9 ай бұрын
Do you tutor? My god it's so fun listening to you!
@TheBeginningOfMusic
@TheBeginningOfMusic 9 ай бұрын
Amazing video, thank you so much for this!
@minuteman1043
@minuteman1043 9 ай бұрын
I've never seen an explanation of Quaternions that simple and clear. Thanks!
@vinipossatto9586
@vinipossatto9586 9 ай бұрын
This video is so useful!!
@henryreed8112
@henryreed8112 9 ай бұрын
Please continue this series
@hikenone
@hikenone 9 ай бұрын
thankyouuu ! for making this video, this is very helpful
@defman21
@defman21 9 ай бұрын
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?)
@SDGGames
@SDGGames 9 ай бұрын
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.
@blu3260
@blu3260 5 ай бұрын
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...
@SDGGames
@SDGGames 5 ай бұрын
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 :)
@jorgesanzana4262
@jorgesanzana4262 8 ай бұрын
this was so good, deserves more views
@F0XxX98
@F0XxX98 9 ай бұрын
This video is insanely good
@makebreakrepeat
@makebreakrepeat 8 ай бұрын
I'm actually really excited for projections! I'd like to do more with cameras, screens and portals 😊
@the-guy-beyond-the-socket
@the-guy-beyond-the-socket 9 ай бұрын
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
@AsatteGames
@AsatteGames 9 ай бұрын
Thanks a lot for the video, I will be using NodePath a lot :)
@RedEyedJedi
@RedEyedJedi 7 ай бұрын
More reasons to procrastinate, exactly what I need.
@WildGrowthJ
@WildGrowthJ 9 ай бұрын
Well done
@zucankidev
@zucankidev 9 ай бұрын
Thanks for making such a useful series.
@kritik_mb2144
@kritik_mb2144 9 ай бұрын
This is a great video, Thank you!!
@connorjade5460
@connorjade5460 4 ай бұрын
Please make one where you cover all the class names like DirAccess and FileAccess in gdscript for godot 4.
@Blender.Quebec
@Blender.Quebec 8 ай бұрын
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 :-)
@SDGGames
@SDGGames 8 ай бұрын
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.
@Blender.Quebec
@Blender.Quebec 8 ай бұрын
Thx a lot ! That is answering my question brilliantly :-) @@SDGGames
@PrueferAuge
@PrueferAuge 5 ай бұрын
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...
@UsaraDark
@UsaraDark 8 ай бұрын
1:17 yeah, i'm totally not procrastinating
@RealPigeonz
@RealPigeonz 9 ай бұрын
Wow... Amazing tutorial bro... just wow. Instant sub from me 😊
@SDGGames
@SDGGames 9 ай бұрын
Thanks! Glad it was helpful
@makebreakrepeat
@makebreakrepeat 8 ай бұрын
Huh, I didn't even know godot had the walrus operator.
@Morimea
@Morimea 9 ай бұрын
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.
@halimghani
@halimghani 8 ай бұрын
best
@FierceMods
@FierceMods 9 ай бұрын
I think the byte math was wrong
@sheepcommander_
@sheepcommander_ 9 ай бұрын
thank youu
@glassmarble996
@glassmarble996 9 ай бұрын
big thanks.
@왜못할거라생각해
@왜못할거라생각해 8 ай бұрын
Wtf your doing engineering XD 😂😅😊
@sancho_tem
@sancho_tem 9 ай бұрын
Wait, I thought var means for variable
@SDGGames
@SDGGames 9 ай бұрын
That's the question
@sheepcommander_
@sheepcommander_ 9 ай бұрын
wait you can put a carrot in front of a string and select nodes??? wtf woah
@sheepcommander_
@sheepcommander_ 9 ай бұрын
caret* lmfao
@SDGGames
@SDGGames 9 ай бұрын
Yeah, it blew my mind a little. I don't think I've ever heard someone talk about that type.
@majorgnu
@majorgnu 9 ай бұрын
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_
@sheepcommander_ 9 ай бұрын
@@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?
@majorgnu
@majorgnu 9 ай бұрын
@@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.
@markstumbris7824
@markstumbris7824 9 ай бұрын
@export_range🤯 thanks!
Every 2D Body Used and Explained - Godot 4.2 Tutorial
31:51
SDG Games
Рет қаралды 4,5 М.
Godot's Quaternion Variant is Beautiful (and misunderstood)
18:52
МЕБЕЛЬ ВЫДАСТ СОТРУДНИКАМ ПОЛИЦИИ ТАБЕЛЬНУЮ МЕБЕЛЬ
00:20
Nastya and balloon challenge
00:23
Nastya
Рет қаралды 56 МЛН
So Cute 🥰
00:17
dednahype
Рет қаралды 58 МЛН
Пришёл к другу на ночёвку 😂
01:00
Cadrol&Fatich
Рет қаралды 10 МЛН
My Experience Moving to Godot from Unity
16:54
DarkDax
Рет қаралды 24 М.
It's Hard To Make Games
18:01
Acerola
Рет қаралды 244 М.
Adding some juicy driving to my game in GODOT
12:08
Deez Gamez
Рет қаралды 3,4 М.
I Made Minecraft in Godot
28:36
RachelfTech
Рет қаралды 44 М.
The Game Dev Who Defined Nostalgia
19:33
Cubit
Рет қаралды 67 М.
How A Steam Bug Deleted Someone’s Entire PC
11:49
Kevin Fang
Рет қаралды 995 М.
I Made The Ultimate Cheating Device
9:39
ChromaLock
Рет қаралды 840 М.
I Created My Own Custom 3D Graphics Engine
26:29
Inkbox
Рет қаралды 72 М.
I accidentally made Blender in Godot
10:15
SDG Games
Рет қаралды 48 М.
Optimizing my Game so it Runs on a Potato
19:02
Blargis
Рет қаралды 579 М.
МЕБЕЛЬ ВЫДАСТ СОТРУДНИКАМ ПОЛИЦИИ ТАБЕЛЬНУЮ МЕБЕЛЬ
00:20