Godot 4 | Signals In Depth Overview

Поделиться
HTML-код
  • Опубликовано: 25 авг 2024

Комментарии • 117

  • @codynosaur
    @codynosaur 10 месяцев назад +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!

    • @JumboGamedev
      @JumboGamedev  10 месяцев назад +1

      You are welcome. Thank you!

  • @Dracalis
    @Dracalis 11 месяцев назад +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  10 месяцев назад +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 10 месяцев назад +7

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

    • @JumboGamedev
      @JumboGamedev  10 месяцев назад +3

      @@Dracalis You are very welcome : )

    • @brabes76
      @brabes76 9 месяцев назад

      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  9 месяцев назад

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

  • @nostalgianinja
    @nostalgianinja Год назад +13

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

    • @JumboGamedev
      @JumboGamedev  Год назад

      Thank you!!! 🙂

    • @w花b
      @w花b Год назад

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

    • @JumboGamedev
      @JumboGamedev  Год назад

      @@w花b Thank you!

  • @damgaronfire
    @damgaronfire 5 месяцев назад +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 !

    • @JumboGamedev
      @JumboGamedev  5 месяцев назад

      Thank you, much appreciated!

  • @Ahenian
    @Ahenian 10 месяцев назад +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.

    • @JumboGamedev
      @JumboGamedev  10 месяцев назад +1

      Good note! Thank you for sharing!

  • @ElmTheWar
    @ElmTheWar 26 дней назад

    I love how casually you used PI, such elegance!

  • @DOT_
    @DOT_ Год назад +4

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

  • @BetaTester704
    @BetaTester704 Год назад +3

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

  • @spencergellner5471
    @spencergellner5471 3 месяца назад +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.

  • @BunnyGunGames
    @BunnyGunGames 4 месяца назад

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

  • @MH-lr6ue
    @MH-lr6ue 4 месяца назад

    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  4 месяца назад

      You are very welcome! Glad you enjoyed the video!

  • @AtelicDev
    @AtelicDev 5 месяцев назад

    That was the best tutorial I've ever seen!

  • @TheRythimMan
    @TheRythimMan 10 месяцев назад +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  10 месяцев назад +1

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

    • @MixMastaCopyCat
      @MixMastaCopyCat 8 месяцев назад

      @@JumboGamedev Observer pattern rules!

  • @MattWyndham
    @MattWyndham 6 месяцев назад

    Thanks this is awesome! I love connecting via Code

  • @pietraderdetective8953
    @pietraderdetective8953 11 месяцев назад

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

  • @heitorteixeiramartinsdossa9334
    @heitorteixeiramartinsdossa9334 6 месяцев назад

    I really like the way you teach!

  • @Betegfos
    @Betegfos Год назад +3

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

    • @JumboGamedev
      @JumboGamedev  Год назад +2

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

  • @635574
    @635574 4 месяца назад

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

  • @user-xs1bv6ns5b
    @user-xs1bv6ns5b 2 месяца назад

    Great tut!

  • @albert69Einstein
    @albert69Einstein 4 месяца назад +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  4 месяца назад

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

  • @Dsibayproduction
    @Dsibayproduction 3 месяца назад +1

    Good job 👍

  • @FaceofFrequency
    @FaceofFrequency 5 месяцев назад

    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.

  • @PurpleMage560
    @PurpleMage560 Год назад +2

    keep doing

  • @bitbraindev
    @bitbraindev 11 месяцев назад

    Great tutorial!

  • @trashy_fgc
    @trashy_fgc 8 месяцев назад

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

    • @trashy_fgc
      @trashy_fgc 8 месяцев назад

      no one messaged me...

    • @JumboGamedev
      @JumboGamedev  8 месяцев назад +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 8 месяцев назад

      @@JumboGamedevnot a complaint at all just funny haha

    • @JumboGamedev
      @JumboGamedev  8 месяцев назад +1

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

  • @toddlask
    @toddlask Год назад +2

    nice job!

    • @JumboGamedev
      @JumboGamedev  Год назад +1

      Thank you :)

    • @toddlask
      @toddlask Год назад

      @@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  Год назад

      @@toddlask Yes, for sure!
      - There is this video about scene and scene instanation: ruclips.net/video/NwpCjyoNYHA/видео.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 Год назад

      @@JumboGamedev cool thx

  • @eason9
    @eason9 4 месяца назад +1

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

    • @JumboGamedev
      @JumboGamedev  4 месяца назад

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

  • @PorcoPorchetto
    @PorcoPorchetto 3 месяца назад

    This is gold

  • @juansnyders7323
    @juansnyders7323 Год назад

    Deserves a lot more subs

  • @CristianAvellino
    @CristianAvellino 11 месяцев назад

    Thanks

  • @alfredogodoy6854
    @alfredogodoy6854 10 месяцев назад

    nice!

  • @zaclownoverheavenalternati6322
    @zaclownoverheavenalternati6322 4 месяца назад

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

    • @JumboGamedev
      @JumboGamedev  4 месяца назад

      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?

  • @mrdadox
    @mrdadox 2 месяца назад

    thx

  • @martinmajewski
    @martinmajewski Год назад +1

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

    • @JumboGamedev
      @JumboGamedev  Год назад +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 Год назад

      @@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  Год назад +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 11 месяцев назад

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

  • @zak-ks7ee
    @zak-ks7ee 9 месяцев назад

    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  9 месяцев назад +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.

  • @ecengclub7196
    @ecengclub7196 4 месяца назад

    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__ 9 месяцев назад

    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  8 месяцев назад

      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.

  • @westingtyler1
    @westingtyler1 11 месяцев назад

    but what's the music in the video?

    • @JumboGamedev
      @JumboGamedev  11 месяцев назад +1

      Stark Goes Dark - The Whole Other

  • @RandomNewb
    @RandomNewb Год назад

    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  Год назад +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 Год назад

      @@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 11 месяцев назад +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 11 месяцев назад +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  11 месяцев назад

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

  • @TheBoEoSoT
    @TheBoEoSoT 11 месяцев назад

    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  11 месяцев назад +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 11 месяцев назад

      @@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  11 месяцев назад

      ​@@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 11 месяцев назад

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

    • @JumboGamedev
      @JumboGamedev  11 месяцев назад

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

  • @jimmyneutron129
    @jimmyneutron129 11 месяцев назад

    so signals = events?

    • @JumboGamedev
      @JumboGamedev  11 месяцев назад

      Yes, they are very similar concepts.

  • @Unskilledcrab
    @Unskilledcrab 11 месяцев назад

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

    • @JumboGamedev
      @JumboGamedev  11 месяцев назад

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

  • @JavaJack59
    @JavaJack59 11 месяцев назад

    Pleasant animations. What do you use to make them?

    • @JumboGamedev
      @JumboGamedev  10 месяцев назад +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). : )

  • @mygamesm
    @mygamesm 7 месяцев назад

    wysi likes