Every Variant in Godot 4

Поділитися
Вставка
  • Опубліковано 22 січ 2025

КОМЕНТАРІ • 59

  • @SDGGames
    @SDGGames  Рік тому +17

    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 Рік тому

      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 Рік тому

      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 Рік тому +30

    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 Рік тому +4

    Happy I found this channel. A competent programmer walking me through items in Godot's class reference document is refreshing. (no distractions, just information)

  • @TheYagich
    @TheYagich Рік тому +3

    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.

  • @frechjo
    @frechjo Рік тому +2

    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  Рік тому +2

      Thanks, I added a correction.

  • @paulmaguire872
    @paulmaguire872 9 місяців тому +1

    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 Рік тому +4

    Some useful and great stuff.....bring on more please.

  • @AliceAlexandra-d5t
    @AliceAlexandra-d5t Рік тому +1

    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.

  • @origenydestino13
    @origenydestino13 9 місяців тому

    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!

  • @minuteman1043
    @minuteman1043 Рік тому

    I've never seen an explanation of Quaternions that simple and clear. Thanks!

  • @Ocdib
    @Ocdib Рік тому +2

    Do you tutor? My god it's so fun listening to you!

  • @TheBeginningOfMusic
    @TheBeginningOfMusic Рік тому +1

    Amazing video, thank you so much for this!

  • @vinipossatto9586
    @vinipossatto9586 Рік тому +3

    This video is so useful!!

  • @hikenone
    @hikenone Рік тому

    thankyouuu ! for making this video, this is very helpful

  • @henryreed8112
    @henryreed8112 Рік тому +2

    Please continue this series

  • @parloleiton20
    @parloleiton20 Рік тому

    this was so good, deserves more views

  • @halimghani
    @halimghani Рік тому +2

    best

  • @RedEyedJedi
    @RedEyedJedi 11 місяців тому

    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.

  • @makebreakrepeat
    @makebreakrepeat Рік тому

    I'm actually really excited for projections! I'd like to do more with cameras, screens and portals 😊

  • @AsatteGames
    @AsatteGames Рік тому

    Thanks a lot for the video, I will be using NodePath a lot :)

  • @the-guy-beyond-the-socket
    @the-guy-beyond-the-socket Рік тому

    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

  • @F0XxX98
    @F0XxX98 Рік тому

    This video is insanely good

  • @blu3260
    @blu3260 9 місяців тому

    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  9 місяців тому

      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 :)

  • @defman21
    @defman21 Рік тому +1

    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  Рік тому

      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.

  • @kritik_mb2144
    @kritik_mb2144 Рік тому

    This is a great video, Thank you!!

  • @PrueferAuge
    @PrueferAuge 9 місяців тому

    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...

  • @Morimea
    @Morimea Рік тому

    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.

  • @zucankidev
    @zucankidev Рік тому +1

    Thanks for making such a useful series.

  • @The_Crucifix
    @The_Crucifix 3 місяці тому

    you best

  • @RealPigeonz
    @RealPigeonz Рік тому +1

    Wow... Amazing tutorial bro... just wow. Instant sub from me 😊

    • @SDGGames
      @SDGGames  Рік тому

      Thanks! Glad it was helpful

  • @WildGrowthJ
    @WildGrowthJ Рік тому

    Well done

  • @sheepcommander_
    @sheepcommander_ Рік тому +1

    thank youu

  • @RedEyedJedi
    @RedEyedJedi 11 місяців тому

    More reasons to procrastinate, exactly what I need.

  • @connorjade5460
    @connorjade5460 9 місяців тому

    Please make one where you cover all the class names like DirAccess and FileAccess in gdscript for godot 4.

  • @glassmarble996
    @glassmarble996 Рік тому

    big thanks.

  • @UsaraDark
    @UsaraDark Рік тому

    1:17
    yeah, i'm totally not procrastinating

  • @Blender.Quebec
    @Blender.Quebec Рік тому

    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  Рік тому

      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 Рік тому

      Thx a lot ! That is answering my question brilliantly :-) @@SDGGames

  • @FierceMods
    @FierceMods Рік тому

    I think the byte math was wrong

  • @makebreakrepeat
    @makebreakrepeat Рік тому

    Huh, I didn't even know godot had the walrus operator.

  • @sheepcommander_
    @sheepcommander_ Рік тому

    wait you can put a carrot in front of a string and select nodes??? wtf woah

    • @sheepcommander_
      @sheepcommander_ Рік тому

      caret* lmfao

    • @SDGGames
      @SDGGames  Рік тому

      Yeah, it blew my mind a little. I don't think I've ever heard someone talk about that type.

    • @majorgnu
      @majorgnu Рік тому

      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_ Рік тому

      @@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 Рік тому

      @@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.

  • @sancho_tem
    @sancho_tem Рік тому

    Wait, I thought var means for variable

  • @왜못할거라생각해
    @왜못할거라생각해 Рік тому +1

    Wtf your doing engineering XD 😂😅😊

  • @Comdevsunion
    @Comdevsunion Рік тому

    @export_range🤯 thanks!