Communicating between game objects with the observer pattern

Published: 02 June 2022
on channel: The Shaggy Dev
7,768
502

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


Watch video Communicating between game objects with the observer pattern online, duration hours minute second in high quality that is uploaded to the channel The Shaggy Dev 02 June 2022. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 7,768 times and liked it 502 visitors.