Godot 4 | Signals In Depth Overview

Sdílet
Vložit
  • čas přidán 22. 08. 2024

Komentáře • 117

  • @codynosaur
    @codynosaur Před 10 měsíci +18

    Holy cow, I have spent two days trying to understand how to connect my nodes with code and you explained better in 3 minutes than most 30 minute videos. Thank you!

  • @Dracalis
    @Dracalis Před 10 měsíci +72

    This is well explained, but I have a critique on presentation. For other videos like this, can you crop and zoom into your code? Most of the screen space you show during the coding part is unused and doesn't need to be there. If you deleted it, you could show the code bigger on screen. I watched this on a phone, and could barely read it.

    • @JumboGamedev
      @JumboGamedev  Před 10 měsíci +14

      Thank you for the feedback. I agree! In some later videos, I started showing the code only and cropping out the other parts of Godot's editor; I will make sure to keep that in mind and prioritize readability : )

    • @Dracalis
      @Dracalis Před 10 měsíci +7

      @@JumboGamedev Oh, good to know! I just switched from Unity to Godot, so I'll check those out. Thank you!

    • @JumboGamedev
      @JumboGamedev  Před 10 měsíci +3

      @@Dracalis You are very welcome : )

    • @brabes76
      @brabes76 Před 9 měsíci

      I like the format of the flow charts and animations to future drive the concepts.
      Request: can you do a (simple) finite state machine using a node based approach. Example characterbody2d as the parent, STATE machine node, then node of each additional state. For some reason i am trying to wrap my head around this concept and i think your approach would clarify this concept.

    • @JumboGamedev
      @JumboGamedev  Před 9 měsíci

      @@brabes76 Are you referring to something like this:
      `CharacterBody2D (Parent)
      |-- idleStateNode
      |-- walkingStateNode...`
      And the script of the CharacterBody2D contains the logic that handles the character's state transitions, right?

  • @damgaronfire
    @damgaronfire Před 5 měsíci +1

    Very good explaination, I seriously think this should be recommended to everyone trying to learn Godot, 3 short minutes and BAM, you already know how signals work !

  • @nostalgianinja
    @nostalgianinja Před rokem +13

    Really nice and succint. All the information needed to understand signals! Thank you!!!

    • @JumboGamedev
      @JumboGamedev  Před rokem

      Thank you!!! 🙂

    • @w花b
      @w花b Před rokem

      The animations really add a nice feel to the video as well. I agree

    • @JumboGamedev
      @JumboGamedev  Před rokem

      @@w花b Thank you!

  • @ElmTheWar
    @ElmTheWar Před 24 dny

    I love how casually you used PI, such elegance!

  • @Ahenian
    @Ahenian Před 10 měsíci +12

    You didn't mention that custom signals are mandatory when you need to emit a signal from a scene into another scene. For example, the player enters a house inside a level scene, the house scene has an area2d to detect the player, and now you need to change the level scene in the player is in from outside to inside. The area2d entered signal needs to be re-emitted by the house scene as a custom signal, so you can connect the level manager to know that now it should change scene.

  • @spencergellner5471
    @spencergellner5471 Před 3 měsíci +1

    Really well done only note would be to place your explanation images within the black space of the script editor portion so the actual code / editor can be seen clearer.

  • @DOT_
    @DOT_ Před rokem +4

    This was so cool🤩🤩
    Please continue and don't stop ❤

  • @MH-lr6ue
    @MH-lr6ue Před 4 měsíci

    Thank you for this video. It puts together all the puzzle pieces in my mind. I understood how to create a custom signal and I knew I would emit it in the same script. but now i understand how to connect it to a function. sweeeet!!

    • @JumboGamedev
      @JumboGamedev  Před 3 měsíci

      You are very welcome! Glad you enjoyed the video!

  • @TheRythimMan
    @TheRythimMan Před 9 měsíci +1

    New to Godot and game engines in general but signals remind me a lot of the event object in JavaScript. Seems like a significantly more efficient way of doing things rather than running an IF statement on every loop of the game engine. I was pleased to see Godot had a feature like this and it's easy to use.

    • @JumboGamedev
      @JumboGamedev  Před 9 měsíci +1

      Me too. I always feel like Godot has a lot of similarities with DOM and events.

    • @MixMastaCopyCat
      @MixMastaCopyCat Před 8 měsíci

      @@JumboGamedev Observer pattern rules!

  • @BunnyGunGames
    @BunnyGunGames Před 4 měsíci

    thanks - it helped me understand the new Signals syntax better.

  • @AtelicDev
    @AtelicDev Před 5 měsíci

    That was the best tutorial I've ever seen!

  • @BetaTester704
    @BetaTester704 Před rokem +3

    Thank you so much.
    Was having so much trouble with this.

  • @pietraderdetective8953
    @pietraderdetective8953 Před 10 měsíci

    this helps a lot to understand how signals works in Godot..great video!

  • @MattWyndham
    @MattWyndham Před 6 měsíci

    Thanks this is awesome! I love connecting via Code

  • @635574
    @635574 Před 4 měsíci

    I didnt know you can define custom signals, that should be pretty useful, for example double click or long press.

  • @albert69Einstein
    @albert69Einstein Před 4 měsíci +1

    i like the graphics, hel[ped solidify my previous knowledge of signals. thank you.
    code was a little small even on laptop. bump up scale by +10-25%

    • @JumboGamedev
      @JumboGamedev  Před 4 měsíci

      Thank you for the feedback. I agree! In some later videos, I adjusted the scale to make the text more visible.

  • @Betegfos
    @Betegfos Před rokem +3

    Awesome tutorial! Can you make a video on how to implement background loading in Godot 4 with a loading screen?

    • @JumboGamedev
      @JumboGamedev  Před rokem +2

      For sure! I added it to the Todo list : )

  • @heitorteixeiramartinsdossa9334

    I really like the way you teach!

  • @FaceofFrequency
    @FaceofFrequency Před 5 měsíci

    I have to find more videos like this and less full tutorials, I think. Great work, thank you. It would be nice if the sub-window containing your script was bigger. Otherwise, liked the visuals.

  • @user-xs1bv6ns5b
    @user-xs1bv6ns5b Před 2 měsíci

    Great tut!

  • @Dsibayproduction
    @Dsibayproduction Před 3 měsíci +1

    Good job 👍

  • @trashy_fgc
    @trashy_fgc Před 8 měsíci

    Kept glancing at my Gchat window thinking folks were messaging me throughout hahahaha

    • @trashy_fgc
      @trashy_fgc Před 8 měsíci

      no one messaged me...

    • @JumboGamedev
      @JumboGamedev  Před 8 měsíci +1

      @@trashy_fgc I feel like signals give the vibes of a message being received, so I tried to use a sound effect that give this feeling. It turns out, it was not a very smart move : ( I will make sure to use other sound effects for future videos.

    • @trashy_fgc
      @trashy_fgc Před 8 měsíci

      @@JumboGamedevnot a complaint at all just funny haha

    • @JumboGamedev
      @JumboGamedev  Před 8 měsíci +1

      @@trashy_fgc It reminds me of a sound effect of a knocking door I heard some time ago xD

  • @eason9
    @eason9 Před 4 měsíci +1

    Great tutorial! Is it possible to emit and connect signals to different nodes?

    • @JumboGamedev
      @JumboGamedev  Před 4 měsíci

      Thank you! Yes, it is possible to emit and connect signals to different nodes.

  • @PurpleMage560
    @PurpleMage560 Před rokem +2

    keep doing

  • @toddlask
    @toddlask Před rokem +2

    nice job!

    • @JumboGamedev
      @JumboGamedev  Před rokem +1

      Thank you :)

    • @toddlask
      @toddlask Před rokem

      @@JumboGamedev maybe u could do a video on the node tree? and how to mess w it in code.instantiating scenes. stay cool!

    • @JumboGamedev
      @JumboGamedev  Před rokem

      @@toddlask Yes, for sure!
      - There is this video about scene and scene instanation: czcams.com/video/NwpCjyoNYHA/video.html
      - I also added another one on the todo list, that should go over more stuff you can do with scenes in GDscript(eg. changing scenes)

    • @toddlask
      @toddlask Před rokem

      @@JumboGamedev cool thx

  • @bitbraindev
    @bitbraindev Před 10 měsíci

    Great tutorial!

  • @zaclownoverheavenalternati6322

    Great Video! Can you give the name of the editor you used?

    • @JumboGamedev
      @JumboGamedev  Před 4 měsíci

      Thank you! I used davinci resolve to do the edits for the video, and I used audacity to do the edits for the audio. Is that what you meant by editor?

  • @juansnyders7323
    @juansnyders7323 Před rokem

    Deserves a lot more subs

  • @PorcoPorchetto
    @PorcoPorchetto Před 3 měsíci

    This is gold

  • @CristianAvellino
    @CristianAvellino Před 11 měsíci

    Thanks

  • @zak-ks7ee
    @zak-ks7ee Před 9 měsíci

    Question: can you send signals from other scenes that are in said level tree? For example you create an object scene that has its own specific nodes and scripts, but has unique signals that need to be sent to the player/other game object in order for it to work. Do you need to get a reference to the scene and connect the object that you want to subscribe to the signal?

    • @JumboGamedev
      @JumboGamedev  Před 9 měsíci +2

      As you implied, one way is to use the get_node function to get a reference to the scene and connect to the signal. But there are other ways. For example, you can delegate the signal to a common parent (ie. a common parent, like the root of the scene that contains both instances, would receive the signal and this root node would invoke a method on the player/other game node). Another way is to use an autoload, which would contain some signals, and nodes can conveniently connect to the signal they want.

  • @alfredogodoy6854
    @alfredogodoy6854 Před 10 měsíci

    nice!

  • @martinmajewski
    @martinmajewski Před rokem +1

    What about connecting signals to methods between scenes and scene sub-nodes?

    • @JumboGamedev
      @JumboGamedev  Před rokem +2

      Yes, you can connect a signal from the (root) of a scene to a method on one of its sub-nodes (children). Actually, you can connect a signal on a node, to a method of another node, as long as both nodes are in the scene tree.

    • @martinmajewski
      @martinmajewski Před rokem

      @@JumboGamedev So when I want to send signals from one child of scene A to a child of scene B, where scenes A and B are siblings in the main scene, I have to search the parent scene (common scene of A and B) for scene B and connect to the root node of scene B, after which I delegate the call to scene B's children (via tree search, casting, and function calls, or again with new signals)? Is there any other/better way? One use case would be to have the game in scene A and the UI in scene B, e.g.!

    • @JumboGamedev
      @JumboGamedev  Před rokem +1

      you can do it in the UI by right clicking on scene A -> check editable children. This will expose the children of scene A (in the main scene),
      you can do the same to scene B, and connect the children you want to wire together from the UI, like any other signal.
      Or
      You might connect them in code directly (get a reference to the
      child of scene A and the child of scene B. One way to do it is by starting at the root of the main scene or the root viewport (get_node('/root/....') # replace `....` with your path). Once you have access to the node references you can do the connection).

    • @dr.positive
      @dr.positive Před 11 měsíci

      @@martinmajewskior you could create an SignalBus singleton that manages signals globally. Implemented this in C# to programmatically make signals with signatures.

  • @mrdadox
    @mrdadox Před 2 měsíci

    thx

  • @ecengclub7196
    @ecengclub7196 Před 4 měsíci

    I don't think we need to make a signal for fullrotation unless there's other node listen to sprite signal. Nevertheless it's a good tutorial

  • @bivouac__
    @bivouac__ Před 9 měsíci

    I am so angry. Why can't I connect a signal to a different scene from the code inside a scene that emits it? It was such a simple task in Godot 3, but now I can't find a solution. And why would I ever need to connect a signal to the same scene? There are no tasks that require it

    • @JumboGamedev
      @JumboGamedev  Před 8 měsíci

      You can connect to a signal emitted by a node that exists in another scene. If I remember correctly, doing something like that is similar in both Godot 3 and 4.
      Connecting a signal to another node in the same scene could be handy in some cases; for example, if you want multiple nodes in the same scene to react to a change/event that happened to another node in the same scene.

  • @RandomNewb
    @RandomNewb Před rokem

    How about an example of connecting a signal when nodes are not siblings of one another, such as a scene that is instantiated during the game? Is there also a good way to connect a signal from one instantiated scene to another instantiated scene, both being created at different times during the game?

    • @JumboGamedev
      @JumboGamedev  Před rokem +3

      Yes, you can. You can do the connection through code, when you are instantiating the later scene.
      For example, assume you have 3 scenes:
      - main scene (instantiates both scene A and B at different times during the game)
      - scene A (has the node that emits the signal)
      - scene B (has the node that should emit the signal)
      In the script of one of the nodes in the main scene, get a reference to the node that emits the signal in scene A and the node that should receive the signal in scene B. (One way to do it is by starting at the root of the main scene or the root viewport (get_node('/root/....') # replace `....` with your path), then you can do the connection.

    • @RandomNewb
      @RandomNewb Před rokem

      @@JumboGamedev I will try this sometime this week when I have development time and see how it goes. I think I understand, but I need to try it myself by writing code. I really appreciate the explanation!

    • @TriteanRares
      @TriteanRares Před 11 měsíci +1

      ​@@JumboGamedevthat seems like coupling, no? I feel that signals are not intended to be used like an event system just a convoluted way to call a method on another node for which you already have a reference to

    • @dr.positive
      @dr.positive Před 11 měsíci +2

      @@TriteanRaresYeah best way I found a way around coupling connectors is to have a global EventBus written in C# where you can programmatically add user defined signals with call signatures then connect callables to the EventBus’s signal. Its a singleton pattern but it gets the job done so Im not complaining :)

    • @JumboGamedev
      @JumboGamedev  Před 11 měsíci

      @@TriteanRares Yes I agree, this adds coupling, which wouldn't scale too well. Generally, If node A wants another distant node B to do something, I delegate the message to a common ancestor (using signals), and this ancestor should invoke a function on the node B. (BTW. by distant node, I mean a node that is not a descendant or an ancestor of node A)
      Might not be a perfect solution if you have to do this for a lot of nodes. But most of the time I try to keep related nodes close to each other to avoid jumping around the scene tree.
      @dr.positive mentioned a nice solution. I have seen this pattern, and it works great, for large projects.
      You can even combine both patterns and have multiple event buses on different levels of your scene tree.

  • @JavaJack59
    @JavaJack59 Před 10 měsíci

    Pleasant animations. What do you use to make them?

    • @JumboGamedev
      @JumboGamedev  Před 10 měsíci +1

      A mix of blender and after effects. (In the past, I used after effects only).
      OBS (for recording), audacity (for audio), davinci resolve (for editing). : )

  • @TheBoEoSoT
    @TheBoEoSoT Před 11 měsíci

    So.
    Signal = Pizza on the menu
    Connect = Someone who wants to eat pizza
    Function and emit = The restaurant makes some eatable things that will be called pizza.
    Is this correct? I'm trying to understand the concept here. 😅😅

    • @JumboGamedev
      @JumboGamedev  Před 11 měsíci +1

      Interesting analogy :) . I may put it this way:
      - A signal = is the event that a pizza has been cooked.
      - connect = You are telling the restaurant to let you know/notify you everytime a pizza has been cooked (ie. the restaurant sends you a message/notification that let's you know the pizza has been cooked).
      - emit = Everytime the restaurant makes a pizza, it let's us know/notifies us that a new pizza has been made. The reason it notifies us, is because we are connected to this signal. (ie. we asked the restaurant to send a message/notification when it cooks a pizza when we used the connect method)
      In the same sense assume you have 2 nodes:
      - button node: this acts as the restaurant that will notify us when something happens.
      - another node: this acts as the listener/ person waiting for the button node to say something.
      A similar scenario could be:
      - A signal: is the event button is clicked
      - connect: the other node asks the button node to notify it when someone clicks the button.
      - emit: someone has clicked the button, so in response the button node will make sure to notify the other node that someone has clicked the button.
      When the button node emits the signal, the other node will make sure to react by executing the function that you have defined.

    • @TheBoEoSoT
      @TheBoEoSoT Před 11 měsíci

      @@JumboGamedev Thank you, I have more questions😅
      1. So a signal and the emit must be used together all the time, right? It would be pointless if we have a signal but don't emit it?
      2. "When the event button is clicked" Can I write this on other nodes as well? I mean In case I don't want to use signal but I want another node to have the "When the event button is clicked" and act exactly the same. Is there another way to get the pizza from the shop without a connection and the signal?

    • @JumboGamedev
      @JumboGamedev  Před 11 měsíci

      ​@@TheBoEoSoT
      ​1) For custom signals, yes, it would be pointless to define a signal that is never emitted it.
      2) If I understand correctly, you want to execute a function when a button is clicked without using a connection and a signal?
      If this is what you want, I think there may be convoluted and inefficient ways like constantly checking the state of the button in the _process function. But using a signal would be much better for this case.

    • @TheBoEoSoT
      @TheBoEoSoT Před 11 měsíci

      @@JumboGamedevwow, thank you very much for your answer. you're the best.

    • @JumboGamedev
      @JumboGamedev  Před 11 měsíci

      @@TheBoEoSoT You are very welcome. Thank you very much 😁

  • @westingtyler1
    @westingtyler1 Před 11 měsíci

    but what's the music in the video?

  • @Unskilledcrab
    @Unskilledcrab Před 11 měsíci

    Dude.. your message notification sound gives my anxiety, anxiety. Otherwise good overview

    • @JumboGamedev
      @JumboGamedev  Před 11 měsíci

      Not my intention at all, I will make sure to use a different sound effect for future videos.
      Thank you : )

  • @jimmyneutron129
    @jimmyneutron129 Před 11 měsíci

    so signals = events?

    • @JumboGamedev
      @JumboGamedev  Před 11 měsíci

      Yes, they are very similar concepts.

  • @mygamesm
    @mygamesm Před 7 měsíci

    wysi likes