Communicating between game objects with the observer pattern
The Shaggy Dev The Shaggy Dev
16.9K subscribers
6,742 views
0

 Published On Jun 2, 2022

One of the most common issues you'll run into in your game development journey is how to let two unrelated objects communicate with one another in a way that doesn't completely ruin the organization and flexibility of your code. The observer pattern is one potential solution to this problem, and makes it easy to let different game objects communicate with one another without coupling your entire application together. With native support in most languages and game engines, it really is something you should keep in your toolbox. We can also expand upon this concept further and introduce the event bus, a way of letting more distant objects connect to one another while still keeping the flexibility of your code intact.

Text version of this video: https://shaggydev.com/2022/06/01/obse...

More info on the observer pattern: https://gameprogrammingpatterns.com/o...

Background and motivation: 00:00
The observer pattern: 01:34
Observables in practice: 02:52
Global access via an event bus: 05:02
The event bus in practice: 05:31
Final thoughts and further reading: 06:04

show more

Share/Embed