+1
Answered

Trigger Custom event after any "Wait" Unit gives coroutine error

YakDogGames 1 year ago updated by Nikita 1 year ago 9

Hi,

I'm trying to trigger an event after the end of the frame "Wait End of Frame" and I get an error saying:

InvalidOperationException: Port 'enter' on 'WaitForSecondsUnit#4a86c...' can only be triggered in a coroutine.


And this is the screenshot for the flow:

Am I doing something totally wrong here?

Regards.

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
+1

Is the receiving custom event also marked as a coroutine?

I don't think so... Should it be? Didn't see any of that in the docs. I can try tho. But you think it matters?

Yep!  In this case, the custom event is almost a new event, so it is the one that needs the coroutine toggle.

Answered

Indeed, if on the receiving end, your event needs to use coroutine units, it needs to be marked as a coroutine too. Flow is not shared across events, it's a new flow entirely.

Don't understand your statement. The receiving end doesn't need coroutines... are you saying that because the sending part is in a coroutine hence the receiving end should be also? 

+2

Ah, but it does need coroutines, as wait units require coroutines to execute.  The error here is because of the after the receiving Custom Event unit, and that event needs to be marked as a coroutine.  (here, your End of Frame needs it too, so you need to keep the On Enable a coroutine too)

How do you mark units as a coroutine? is there an option or something? Sorry, i'm new to Bolt

+2

hidden bool :0)