+3
Fixed

Coroutine transitions lead to multiple active states

Reality.Stop() 7 months ago • updated by Lazlo Bonin (Lead Developer) 6 months ago 10 1 duplicate

There isn't anything about the downward flows (they just wait for a second before transitioning, but the upper right branch has this:

which is a long enough delay that when it fires the source state is no longer active, yet the trigger transition still occurs.

Here's a macro for it (slightly cleaned up from the .gif)

bolt breaker.asset

Bolt Version:
Unity Version:
.NET Version:

Duplicates 1

Working on Fix

Yep, this is a design issue.

The problem is that coroutines created inside a flow graph do not automatically stop when that graph stops listening.

This is something I intended to fix only for Bolt 2, but it seems like an urgent issue to me now. There are workarounds, but they're all quite ugly.

+1
Fixed in Next Version

Fixed for v.1.4.0f10. The new behaviour will be that whenever an event marked as a coroutine stops listening (whether because its parent state exited, because its machine was disabled, or because it was deleted), the coroutines it started will be stopped.

That may be a breaking change for some people who relied on coroutines running beyond a disabled object, but I doubt that's a common use case at all. The upgrade notes will include a warning regardless.

It just looks like this:

+1
Under Review

Hi Terry! This seems related to another issue which I'm fixing for v.1.4.0f10, merging your thread.

My transitions stopped working and can't figure out why :( 

Error: 

NotSupportedException: Stop may only be called on coroutines.
Bolt.Flow.StopCoroutine ()
Bolt.EventUnit`1[Bolt.EmptyEventArgs].StopListening (Ludiq.GraphStack stack)
Bolt.FlowGraph.StopListening (Ludiq.GraphStack stack)
Bolt.SuperUnit.StopListening (Ludiq.GraphStack stack)
Bolt.FlowGraph.StopListening (Ludiq.GraphStack stack)
Bolt.FlowStateTransition.OnExit (Bolt.Flow flow) (at C:/Users/lazlo/Projects/Bolt1/Package/Bolt.State/Runtime/FlowStateTransition.cs:81)
Bolt.State.OnExit (Bolt.Flow flow) (at C:/Users/lazlo/Projects/Bolt1/Package/Bolt.State/Runtime/State.cs:194)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
Bolt.Flow:StartCoroutine(ControlOutput, ICollection`1)
Bolt.EventUnit`1:Run(Flow)
Bolt.EventUnit`1:Trigger(GraphReference, EmptyEventArgs)
Bolt.<>c__DisplayClass14_0:b__0(EmptyEventArgs)
Bolt.EventBus:Trigger(EventHook, EmptyEventArgs) (at C:/Users/lazlo/Projects/Bolt1/Package/Bolt.Core/Runtime/Events/EventBus.cs:65)
Bolt.EventMachine`2:TriggerRegisteredEvent(EventHook, EmptyEventArgs) (at C:/Users/lazlo/Projects/Bolt1/Package/Bolt.Core/Runtime/Events/EventMachine.cs:42)
Bolt.EventMachine`2:TriggerEvent(String) (at C:/Users/lazlo/Projects/Bolt1/Package/Bolt.Core/Runtime/Events/EventMachine.cs:14)
Bolt.EventMachine`2:FixedUpdate() (at C:/Users/lazlo/Projects/Bolt1/Package/Bolt.Core/Runtime/Events/EventMachine.cs:99)

Problem solved by removing coroutines from transitions

+1

Can you start a new topic & send the macro(s) that cause this bug? 

It's probably an easy to fix oversight from my implementation of automated coroutine stop.