0
Answered

Multiple Same Lifecycle Event Listeners

Guy Rabiller 2 years ago updated 2 years ago 3

1) Is it ok to add the same Lifecycle Event multiple times in the same flow graph or state node ?

2) Is it ok to have a Lifecycle Event inside a Super Unit (embed or macro) that is already present in the root node ?

For instance, lets say I want to encapsulate complex physics behaviors for an item, encapsulated into 2 Super Units, one for rotation, one for moving (both are independent). In my flow graph, I would then have 2 Super Units, and inside each one of those there would be a Fixed Update Event listener. So I would just drop the macro into the node and that's it, no connection needed.

Is that legit ? Designed for ?

Beyond that example it is a graph design question, so instead of connecting a bunch of nodes, then you just drop several macros that have embedded event(s) listener(s) and that's it, no connection needed with the other nodes at the root. 

Would that work without issue ? Even if the node containing those macros also contains the same event listener at its root ?

Also having the same Event listener multiple time in the same graph for nodes organization purpose, so you don't have extra long connections for instance, is that ok ? Any issue ?

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
GOOD, I'M SATISFIED
Satisfaction mark by Guy Rabiller 2 years ago

That also poses the question of order of execution, if multiple same event listeners are used, either at the same "level" or mixed between nodes and its embedded super units.

+2
Answered

Hi Guy! It is perfectly valid to have multiple same lifecycle event listeners, even in nested graphs, however the order of execution is undefined. There is no guarantee, for example, that Updates in top level graph would execute before or after those in nested graphs.

That's perfectly fine with me. If a specific order of execution need to be respected then.. connections : ) Thanks again Lazlo, Bolt is awesome.