such a good example / explanation of custom signals, i was struggling to understand how/when you'd pass arguments through a signal until now, thank you!
I don't think you can use signals as events in for example .Net, however you could implement a signals hub that ties stuff together. Why you would use a signal if you already need a reference to the node, beats me
Super helpful video for someone new to Godot. I followed along and then immediately tried to replicate your steps from memory; it helped a lot. Hope things are well, Brett!
I did this today! Created my own signal for spawning a laser for an asteroid esq game (inspired by your own prototypes), and also used built-in signals to end the laser when it leaves the screen! 😁 Your videos are quite advanced for someone brand new to Godot/coding, but it feels awesome to get to the point of watching back and understanding some of the points. Saw you created a patreon and have joined to support your journey to full-time indie dev
Way to go! That's awesome. Thanks so much for your support on the Patreon, it means a lot. I plan on doing some more beginner friendly Godot and game programming videos in the future. I've been thinking about it a lot, and Godot has a lot of concepts that could be overwhelming for someone totally new to it. Going to think about ways to explain and focus on making it more approachable.
Awesome explanation, I would like to connect a signal from an enemy to a global script that keeps track of stuff. Is it possible to connect the signal before the enemy was even spawned or shall I use static functions instead of singals? XD
How? Do you mean the "$" reference method? I'm just learning Godot and this connecting scenes and nodes via the editor like this feels like a bad idea. I want to do it inside the scrip.
When you get a node in the code, you can just type out the signal you want to connect and call connect and pass in the callback. Here's the Godot docs on it: docs.godotengine.org/en/stable/getting_started/step_by_step/signals.html#connecting-a-signal-via-code I haven't been covering much code-driven functionality yet in my screecasts, but I intend to. I myself am still figuring out my preferences there. Like when is it best to use the inspect and add scenes myself or when to do it dynamically. From the video, in code, you'd do: $Timer.timeout.connect(_on_timer_timeout) to wire it up with code.
Add a reference var for the node that has the signal. Then write [var or the $nodeName].[signal name].connect([signal function name]). Add optional parameter arguments to the signal function of appropriate.
coding using side effects (and by proxy, signals) seems extremely extremely extremely dangerous! For a small script it looks safe (and it is), but it outscales iself super quickly. Be careful using these! In software engineering in general (not just game development), whenever you think you need to do something with a side-effect, you usually don't! (with some exceptions)
What side effect? Signals are the intended way nodes comunicate their state or data with one another Signals are just like an array of object references, when the signal is called it goes throught that array and tells every object that something happened by calling the deferred method; if theres nothing connected to the signal then no one is called. Is pretty common to do on gamedev when you want thing A to know when thing B did something the exact moment it happens.
@@brettmakesgames I just looked at the video again, was working so first time I was able to check. And I figured it out. you uses print_debug() instead of just print(). This is going to help me out. Thank you.
such a good example / explanation of custom signals, i was struggling to understand how/when you'd pass arguments through a signal until now, thank you!
You're so welcome, Astrid! Glad to hear to it was helpful.
How do you do the connection if both are in different scenes? and Receive signals?
Can you please help me out on that one?
I don't think you can use signals as events in for example .Net, however you could implement a signals hub that ties stuff together. Why you would use a signal if you already need a reference to the node, beats me
OMG, thank you! I've been stuck for a while now completely misunderstanding how signals work, so this was just what I needed. You're the best, Brett.
Nice video, clear and easy to understand, no anoying music, good job
Thanks! I appreciate the feedback. Yeah, I can't handle the consistent bg music and choppy editing of a lot of RUclips videos. 😂
great video brett
I wish I was as great as programming and using Godot as you are! Thanks for the amazing short tutorial!
Super helpful video for someone new to Godot. I followed along and then immediately tried to replicate your steps from memory; it helped a lot. Hope things are well, Brett!
Wow this is really helpful and explains it in such an easy to understand way. Thank you!
Man, you're the best!
you've really helped me in this journey. I love your videos, keep up the good work!
Thanks a lot.
I did this today! Created my own signal for spawning a laser for an asteroid esq game (inspired by your own prototypes), and also used built-in signals to end the laser when it leaves the screen! 😁
Your videos are quite advanced for someone brand new to Godot/coding, but it feels awesome to get to the point of watching back and understanding some of the points. Saw you created a patreon and have joined to support your journey to full-time indie dev
Way to go! That's awesome. Thanks so much for your support on the Patreon, it means a lot. I plan on doing some more beginner friendly Godot and game programming videos in the future. I've been thinking about it a lot, and Godot has a lot of concepts that could be overwhelming for someone totally new to it. Going to think about ways to explain and focus on making it more approachable.
pros and cons of using signals, and the alternative?
Great video, very helpful!
How would you connect the signal in code? The docs don't show how to do it with parameters.
Awesome explanation, I would like to connect a signal from an enemy to a global script that keeps track of stuff. Is it possible to connect the signal before the enemy was even spawned or shall I use static functions instead of singals? XD
thanks, very helpful!
Nice focused video. Thanks.
Thanks, Russ! I appreciate the feedback.
you forgot to mention that you can also connect nodes in code - no need to use the connect way from signals tab in the godot UI
How? Do you mean the "$" reference method? I'm just learning Godot and this connecting scenes and nodes via the editor like this feels like a bad idea. I want to do it inside the scrip.
brilliant video, thank you
Glad it helped, thanks for the kind words!
unity refugee says thank you
how about making connections purely through code?
When you get a node in the code, you can just type out the signal you want to connect and call connect and pass in the callback. Here's the Godot docs on it: docs.godotengine.org/en/stable/getting_started/step_by_step/signals.html#connecting-a-signal-via-code
I haven't been covering much code-driven functionality yet in my screecasts, but I intend to. I myself am still figuring out my preferences there. Like when is it best to use the inspect and add scenes myself or when to do it dynamically.
From the video, in code, you'd do: $Timer.timeout.connect(_on_timer_timeout) to wire it up with code.
@@brettmakesgames I'm having trouble doing it with custom signals.
I'll do some digging into that and share what I learn... haven't had to connect custom signals with code yet!
@@brettmakesgames ty
Add a reference var for the node that has the signal. Then write [var or the $nodeName].[signal name].connect([signal function name]). Add optional parameter arguments to the signal function of appropriate.
coding using side effects (and by proxy, signals) seems extremely extremely extremely dangerous! For a small script it looks safe (and it is), but it outscales iself super quickly. Be careful using these! In software engineering in general (not just game development), whenever you think you need to do something with a side-effect, you usually don't! (with some exceptions)
What side effect? Signals are the intended way nodes comunicate their state or data with one another
Signals are just like an array of object references, when the signal is called it goes throught that array and tells every object that something happened by calling the deferred method; if theres nothing connected to the signal then no one is called.
Is pretty common to do on gamedev when you want thing A to know when thing B did something the exact moment it happens.
Thanks.
I'm wondering is the at: res://main.... how did you get that to show? That would help me a lot.
Would you mind explaining what you mean a little more or sharing a timestamp? Happy to help but unsure what you mean.
Just the main scene.
@@brettmakesgames I just looked at the video again, was working so first time I was able to check. And I figured it out. you uses print_debug() instead of just print(). This is going to help me out. Thank you.
I think I got the gist of it
you're the best
Thanks, Seth!