Limitations of events

How do events work internally and what should I mind when using them, generally?

  • Can any GameObject listen to any event?
  • Can I extend Events?
  • Should I make use of events for normal game systems or should they be relegated to the specific interactions provided?
  • How superior are they to rudimentary ‘if’ statements?

Listeners are just functions, and any function can be a listener.

Listeners that reference game objects must be removed when those objects are destroyed.

If you have an event emitter, you can emit any event you want from it (event names are arbitrary), with any arguments.

See Observer pattern.

1 Like