Faster & Better Access to your GODOT Nodes!

Поділитися
Вставка
  • Опубліковано 1 лют 2024
  • ▶︎ GODOT 4 COURSES : school.gdquest.com/godot-4-ea...
    🎓 FREE APP "Learn GDScript From Zero" : www.gdquest.com
    🎮 FREE INTERACTIVE GODOT TOUR - The Godot Editor - www.gdquest.com/tutorial/godo...
    🗨 *DISCORD INVITE*: / discord
    ------------------------------------------
    🖋 SYNOPSIS
    This video shows you how to access Godot's nodes in the editor more efficiently using unique names and node caching.
    #gamedev #gamengine #godot
    -------------------------------------------
    CC-BY 4.0 LICENSE --- Assets & Videos
    creativecommons.org/licenses/...
    Attribute To: "CC-By 4.0 - GDQuest and contributors - www.gdquest.com/"
    MIT --- Code
    opensource.org/license/mit/
    "Copyright 2024 - GDQUEST.COM"

КОМЕНТАРІ • 70

  • @davidarce6256
    @davidarce6256 4 місяці тому +40

    i love this channel graphic design, is beautiful.

    • @enderproofed5478
      @enderproofed5478 4 місяці тому +2

      Yeah, it's like "Kurz gesagt - In a Nutshell", but for Godot :)

    • @m.raflyyanuar9886
      @m.raflyyanuar9886 4 місяці тому

      I really dig it too! I wonder if this particular style has a name..?

  • @del669
    @del669 4 місяці тому +15

    it's because of clear explanations like these that i've decided to subscribe to your 2d and node course, thank you

  • @emissaryofcharybdis105
    @emissaryofcharybdis105 14 днів тому

    Wow, thank you so much, man. I've been trying to play with values in different scripts for so long now. This is INSANELY easier than anything I've made work thus far.

  • @Gquain
    @Gquain 4 місяці тому +14

    wow i worked 4months on a game demo and just released it yesterday. i never knew it existed, my top block is FILLED with onreadys.
    The takeaway i have from this video is that in almost all cases (if you arent dependent on an external editor) you can always use Unique names and save yourself some code lines (and performance)

    • @Gdquest
      @Gdquest  4 місяці тому +9

      Pretty much plus it kind of doubles as documentation. You can quickly scan a scene and see which nodes are used in code for sure. Then if you make sure all nodes you use in your code have unique names, it's even more useful to quickly spot the others.

  • @danielg9446
    @danielg9446 4 місяці тому

    Love ur chanel man! Ima unity refuge who learning godot but I have only begginer courses and not very up to date,
    Your endless stream of awesome content helps me ALOT to really sink in with this new engine ❤

  • @Limited_Film_Works_
    @Limited_Film_Works_ 4 місяці тому +1

    I didn't know you could do this XD Thanks GDQuest!!

  • @lindeschoon1825
    @lindeschoon1825 3 місяці тому +2

    dude. been using godot for a good month or two now - i had no idea this feature even existed. this is brilliant, thanks a ton! also just now learned you can actually drag nodes into the script editor XD duh!

  • @Weahl
    @Weahl 4 місяці тому

    Awesone video as always!

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

    OMG this is so incredibly useful, thank you!!

  • @DigitalMetal
    @DigitalMetal 4 місяці тому

    Awesome! I had no clue about this feature.

  • @LoganDaugherty-xx7ss
    @LoganDaugherty-xx7ss 4 місяці тому +1

    I’ve been following the GDQuest Learn 2D from zero and it’s been very good. Thank you Nathan and GDquest for your contribution to the Godot community!

    • @Gdquest
      @Gdquest  4 місяці тому +1

      Thanks for your feedback! It's very nice to read :))

  • @draftingish4833
    @draftingish4833 4 місяці тому +1

    Soo good glad I watched this one, it just got rid of my biggest annoyance

  • @Bloodstrikeofficiale
    @Bloodstrikeofficiale 4 місяці тому

    Nice work 😂😊

  • @fusobotic
    @fusobotic 4 місяці тому +9

    Nice! I'm curious how much of a performance increase is it from using regular onready vars?

    • @julienb5815
      @julienb5815 4 місяці тому +2

      Yup, me too. I'm using mostly the $"nodename" syntax and curious if I should bother switching to %"nodename"

    • @HonsHon
      @HonsHon 4 місяці тому

      ​@@julienb5815If it tells it to aggressively cache those references, I can imagine it is quite fast.

    • @Gdquest
      @Gdquest  4 місяці тому +3

      It doesn't make a performance difference with onready variables. It mostly makes a difference with using the $ or generally getting node with nude paths, because instead of reading the path and finding the nodes each time, the reference is cached for you.

    • @julienb5815
      @julienb5815 4 місяці тому

      @@Gdquest Ah good to know. So since I mostly use $ with onready (for typing, too, like you do at 3:05 with %), then no difference 👀 Thanks

    • @pacomatic9833
      @pacomatic9833 4 місяці тому +1

      @@Gdquest you said nude paths...
      Might wanna fix that before UA-cam decides to censor that.

  • @thatcipher
    @thatcipher 4 місяці тому +1

    This sounds very handy - is this also usable with C#?

  • @pipeliner8969
    @pipeliner8969 4 місяці тому

    I pre-ordered all the courses. Looking forward to become a Godot Master

    • @Gdquest
      @Gdquest  4 місяці тому

      😊😊 Hope you enjoy the first modules we released a few days ago for the 2D course. More on the way!

    • @pipeliner8969
      @pipeliner8969 3 місяці тому +1

      @@Gdquest it's so well written! Enjoying it a lot

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

    I would love to support and learn from your course, but unfortunelly in my country this course is almost as much as a minimum wage. But I love your videos, I learn so much with them, keep up the good work :)

    • @Gdquest
      @Gdquest  3 місяці тому +1

      I completely understand that's why we offer regional pricing. We're still implementing it on our new site but if you like, you can email us at support@gdquest.com and we'll send you a coupon that adjusts the price to your country so you don't have to spend a month's wages on the course.

  • @oussama7132
    @oussama7132 4 місяці тому

    is it better than using a singleton pattern? like for game managers? also i hope an extension for visual studio or visual studio code is made so the last part in the video will not be necessary anymore

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

    This is cool ❤as always,
    🤔
    but can it really save performance
    I mean I still have to make on ready variabls can it really make the performance better?
    I love to know

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

    2:11 at part
    %PlasmaGun.shoot()
    Is that a custom function call from plasma gun node?
    Like in plasma gun script it has func _shoot() ?
    We can reference it like that? Or that's only certain syntax like .play()/.show()/.hide() ?

  • @BryceDixonDev
    @BryceDixonDev 4 місяці тому +5

    Here's a pattern I started using in Unity a few years back I call the "deferred caching getter" (useful when you can't or don't want to use `@onready`):
    ```
    var thing: Type:
    get:
    if not is_instance_valid(thing):
    thing = get_tree().current_scene.get_node_or_null(^"Thing")
    return thing
    ```
    This is really useful for accessing scene-relative objects that don't have a specific relationship to your script (eg: the player) or have an inconsistent lifetime (eg: fired projectiles, sound emitters, or particle effects)

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

      Now if only GDScript had better metaprogramming, you could encapsulate that in something like @cached_property

  • @adventuretuna
    @adventuretuna 8 днів тому

    What happens when you rename the node? Will it rename the references in the script?
    I don't like how it relies on a string (the name of the node), which can be changed by anyone working in the project.
    Export tag and dragging the node in the inspector seems a much better solution than this.

  • @HonsHon
    @HonsHon 4 місяці тому

    For anyone who works on the engine, is there a performance increase (better caching or something?) over just making variable references?
    Such as:
    --------
    var camera : Camera3D = null
    func _ready():
    camera = $Camera3D
    --------
    Or is this just a more convenient way of doing the same thing?
    (I know I can use onready, but I am not a huge fan of using that)

    • @Gdquest
      @Gdquest  4 місяці тому

      It doesn't make much of a difference with creating onready variables and storing the reference there. It mostly makes a big difference for people who constantly get the nodes using the $ notation and node paths. And if you prefer, it can remove the need for onready variables.

    • @HonsHon
      @HonsHon 4 місяці тому

      ​@@Gdquest sweet, thank you. I was making sure I had it right in my head.

  • @zzzzzzzzzzzzzzzzzzzzzzzzzzzz__
    @zzzzzzzzzzzzzzzzzzzzzzzzzzzz__ 2 місяці тому

    What about using an export tag and dropping nodes in? Wouldn’t this be more modular?

  • @teo2805
    @teo2805 4 місяці тому

    An advantage of this is that it can work across scenes right? For example my player scene will be able to access my %World scene directly right?

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

      Unfortutantely no :/

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

      @@tomaszgoral8154 dawww!

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

    Why not just use @export var? Hardcoded references just don't seem like a good idea since you could change the name, change location, or remove it altogether. In Godot 4.2, if you drag the reference in the editor to an exported variable, then the reference automatically updates if you make changes to it in the editor. It's better than adding a file path since the path changes automatically in reference, and you only need to drag it in. It's better than the modulus unique name reference because you don't need a unique name either. What's the tradeoffs?

  • @garmiklik
    @garmiklik 4 місяці тому +2

    I was excited until you mentioned the typing downside :(
    Still good to know, didn't know this was added, good stuff.

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

    Is there a way to check for a cached node? In other words, if I have a node, and I want to check if it exists or not, but I don't always know in the scene where it will be, so I can't use "has_node"?

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

      There is "find_node" but I would recommend reviewing your architecture so you don't have to use it.

  • @Kaedric999
    @Kaedric999 4 місяці тому

    does the % naming use static typing? your lines are marked as unsafe in the editor

    • @Kaedric999
      @Kaedric999 4 місяці тому +2

      I should watch a whole video before I comment lol

  • @JamesKelly89
    @JamesKelly89 4 місяці тому

    How does this work with scene instances? Will having multiple instances of the same scene cause any conflicts?

    • @KyleRassweiler
      @KyleRassweiler 4 місяці тому

      Not that I've seen so far

    • @refeals
      @refeals 4 місяці тому +1

      it's local to the scene

    • @CrimsonBlasphemy
      @CrimsonBlasphemy 4 місяці тому +3

      The % UniqueName is stored to the Owner node of the Scene (the instance of the PackedScene). As a C++ hashmap (think GDScript dictionary). When you get_node $ , one of the first checks done is for the % token. Which will then check the Node's Owner for a match in that hashmap. And return the Node reference stored there. Duplicate instances will use the hashmap in that particular Owner. So there's no conflict.

  • @rluis
    @rluis 4 місяці тому +1

    Just a note... in 4.2, the typing is not working when using nodes referenced with $ as well, even if the scene is open and active.

    • @Gdquest
      @Gdquest  4 місяці тому +1

      Thanks for pointing this out! I hadn't paid attention to this. I hope they bring it back.

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

    I'm using Godot 3.5 but it shows a tokenizer error how to fix this?

  • @ZoidbergForPresident
    @ZoidbergForPresident 4 місяці тому

    Hello! Bientôt les version G4 des courses? :D

    • @Gdquest
      @Gdquest  4 місяці тому

      Hello back! Oui ! Nous avons déjà commencé à publier les modules de Learn 2D Gamedev.

  • @tommysedin
    @tommysedin 4 місяці тому

    Am I the only one having problems getting code completion to work when using unique names? I notice that GDQuest is getting code completion for .current on his camera, I only get the stuff from Node. Currently running v4.2.1, but same issue in earlier v4 versions. Is there a setting or something I need?

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

      works fine for me. you using a % or $ symbol?

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

      Just "%Camera2D." and after typing the period the code completion pops up but only contains stuff from Node.@@ince55ant

  • @containedhurricane
    @containedhurricane 4 місяці тому

    Nice. Unfortunately, it's not available in C#

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

    This works with c#?

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

    What about those students (like me) who can't afford to buy your courses, but are genuinely interested in Godot Game dev Professionally?

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

      We also offer student discounts. Just send me an email to support@gdquest.com using your school email account and let me know what courses you're interested in.
      Alternatively, talk to your school/uni and see if they're interested in using the course. We have a program for schools that is really accessible for public institutions and that includes the whole learning pathway.

  • @papaepgamer2023
    @papaepgamer2023 4 місяці тому

    Bro can you make a tutorial godot in mobile please

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

    I use the @onready. Since if you select them and drag them to the editor while pressing CTRL they get automatically added as @onready

  • @teo2805
    @teo2805 4 місяці тому

    What's the difference between this and onready var node = $myNode?
    Edit nvm it's in the video lolol

  • @steeldash740
    @steeldash740 4 місяці тому