Game Programming Patterns in Godot: The Observer Pattern (Godot Signals)

preview_player
Показать описание
👉️ Learn how to implement the Observer pattern in your Godot game!

(Disclosure: As an Amazon Associate I earn from qualifying purchases.)

In this Godot tutorial, I will explain to you what is the Observer Pattern and how it translates to the Godot Game Engine via Godot signals. The Observer Pattern is a widely used game design pattern that can enhance your code by providing a clear separation of concerns and promoting loose decoupling of components. This video is also a Godot Signals Tutorial since the signals in Godot are the concrete implementation of the Observer Pattern. Also, we'll dive deep into the mantra "call down, signal up" to understand when it's recommended to use signals in Godot and when not to.

🔔 Subscribe:

Subscribe to my channel to see more videos like this:

📖 Useful resources:

- More information about Godot Signals in the official Godot Game Engine documentation:
- Another very good Godot Signals Tutorial:

🔵 Follow me:

Find out about my latest videos and publications:

⏳ Timecodes:

00:00 - Introduction on this Godot tutorial
01:14 - Godot Observer Pattern explained
02:27 - Using the Godot signal system
04:23 - Godot custom signals
07:22 - When to use signals
08:22 - Conclusion

---

Music credits:

Track: Alexi, Action, Infraction- Witch's Whispers
Music provided by Infraction No Copyright Music
Рекомендации по теме
Комментарии
Автор

"Call down, signal up" is one of the best explanations of how signals are used that I've seen.

IroquoisPliskin
Автор

Your philosophy "Call down, signal up" makes a lot of sense of how to simply work through the use cases in your mind. I like how short, simple, and clear this video is. Here's a like from me!

I also like how you mention when it's appropriate to add dependencies. Having the World scene have dependencies since it should always have or expect certain nodes but using signals for children that may or may not be used in such a world (such as if you have multiple worlds or they are used elsewhere) to just throw a "Hey, I did this. Somebody handle it." makes a lot of logical sense. I tend to work through these things myself, but it's usually not a clean method in mind like this, so this helps!

TayoEXE
Автор

Very handy and clean way to have separate child scenes talk without have to load sibling nodes constantly.
I never knew it had a pattern name, love ya work.

gtfo
Автор

ty so much!!😊😊 your tutorial is greate❤🎉

RedRebbit
Автор

I do also like this video about the observer pattern in godot!! Nice channel and very nice work 😊

danielsepulveda
Автор

Nice videos so far! I can tell you put a lot of work into those, so big kudos to you. Please never give up!

PascalPeuckert
Автор

I believe you can also emit the signal with the syntax of which is a bit cleaner than passing the name of the signal as a string!

Rossvanzyl
Автор

Dude that’s exactly what I was looking for, a nice intermediate example. I hope you keep making tutorial videos like this!!

the_dude_josh
Автор

7:38 This animation was really distracting. I had to rewind and look away from the screen to focus on what you were saying. Other than that, it was a very helpful video.

textexadecimal
Автор

Observer pattern should really be object1.emit(someEvent), and object2.observe(someEvent, callback). This is more like getting access to both object1 and object2 and connecting them together in some unrelated place which kind of misses the whole point. I should be able to easily subscribe multiple objects to the same event in their classes by just calling some subscribe method.

whatever
Автор

Would be nice to show other scripts registering with the master script. This reduces the child coupling. And allows for dynamic children as well.

htspencer
Автор

1:32 this is not true, using signals is literally like:
func _physics_process(delta):
for o in all_objects:
if area_collided_with_object(o): call_body_entered(o) # it more complex in reality, checking collision mask and layers, but similar
it still continiously checking all colliders to understand when to emit signal

plur_ndbn
Автор

is it possible to do this through scenes? I have a player scene and I want to emit a signal to my main scene, but I have to send it through an autoload script for it to work.

darkrozen
visit shbcf.ru