Best Way to handle numerous game events for a tutorial in Unity?

Started by
1 comment, last by Shaarigan 3 years, 8 months ago

Was wondering what people who use Unity did when they had a tutorial that had multiple events to ‘fire’ to move the tutorial forward. I am aware of Unity Events and the c# Event structure in general, but my issue is that I would have numerous ‘publishing objects' throughout the game (i.e. push a button, hover over an object, gain 20 Power, etc) and for a subscribing object to receive the message they have to have a reference to the publisher. This model would quickly get unwieldy with my game. What have some other people done in this situation, or is there a better event-driven model/plug-in/utility in Unity that would make keeping track of 50+ unique events easier? TIA!

Advertisement

This sounds like a use case for Rx aka Reactive Programming to structure your game in a way that you have event streams instead of single hard-coded event per object. This way, producers can push their events to certain streams and consumers may use those streams and probably concatenate them to more complex event driven reactions. For example for certain states of your tutorial, you could chain events together to determine the tutorial progress.

However, Rx.Net is a big fat library you might not want to use at all, instead of a more lightweight alternative that also plays better with Unity. It is easy to implement your own reactive API once you understood how it works

This topic is closed to new replies.

Advertisement