Reply To: Action doesn't wait for Coroutine end (IEnumerator) to finish

Forums › 💬 NodeCanvas › ⚙️ Support › Action doesn't wait for Coroutine end (IEnumerator) to finish › Reply To: Action doesn't wait for Coroutine end (IEnumerator) to finish

#19440
awsullivan
Participant

    So I’ve been trying to get this to work and I’m having no luck at all. Hopefully I’m missing something obvious but I fear that NC is pretty broken with coroutines and C# events in it’s current state.

    So I have the below test script attached to a cube as well as the FSM below. The script runs and executes the initial wait action and then moves to the next action but simply executes the method and immediately goes green, never catching the event that should cause the FSM to change states. In NC1, the state would remain yellow in the graph until the coroutine finished. Then it would move on if any conditions had been met.

    Here is the FSM export.

    {
    “version”: 2.0,
    “type”: “NodeCanvas.StateMachines.FSM”,
    “name”: “FSM”,
    “comments”: “”,
    “translation”: {
    “x”: -5171.998046875,
    “y”: -4822.998046875
    },
    “nodes”: [
    {
    “_actionList”: {
    “executionMode”: “ActionsRunInParallel”,
    “actions”: [
    {
    “waitTime”: {
    “_value”: 2.0,
    “_name”: null
    },
    “finishStatus”: “Success”,
    “_isActive”: true,
    “overrideAgent”: null,
    “$type”: “NodeCanvas.Tasks.Actions.Wait”
    }
    ],
    “_isActive”: true,
    “overrideAgent”: null
    },
    “_repeatStateActions”: false,
    “_transitionEvaluation”: “CheckContinuously”,
    “_collapsed”: false,
    “_position”: {
    “x”: 5430.0,
    “y”: 5040.0
    },
    “_name”: null,
    “_tag”: null,
    “_comment”: null,
    “_isBreakpoint”: false,
    “$type”: “NodeCanvas.StateMachines.ActionState”,
    “$id”: “1”
    },
    {
    “_actionList”: {
    “executionMode”: “ActionsRunInParallel”,
    “actions”: [
    {
    “functionWrapper”: {
    “result”: {
    “_value”: null,
    “_name”: “”
    },
    “_targetMethod”: {
    “_baseInfo”: “TestScript|Test2SecondCoRoutine”,
    “_paramsInfo”: “”
    },
    “$type”: “NodeCanvas.Framework.Internal.ReflectedFunction1[[System.Collections.IEnumerator, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]”
    },
    “_isActive”: true,
    “overrideAgent”: null,
    “$type”: “NodeCanvas.Tasks.Actions.ExecuteFunction”
    }
    ],
    “_isActive”: true,
    “overrideAgent”: null
    },
    “_repeatStateActions”: false,
    “_transitionEvaluation”: “CheckContinuously”,
    “_collapsed”: false,
    “_position”: {
    “x”: 5580.0,
    “y”: 5220.0
    },
    “_name”: null,
    “_tag”: null,
    “_comment”: null,
    “_isBreakpoint”: false,
    “$type”: “NodeCanvas.StateMachines.ActionState”,
    “$id”: “5”
    },
    {
    “_actionList”: {
    “executionMode”: “ActionsRunInParallel”,
    “actions”: [
    {
    “functionWrapper”: {
    “result”: {
    “_value”: null,
    “_name”: “”
    },
    “_targetMethod”: {
    “_baseInfo”: “TestScript|Test1SecondCoRoutine”,
    “_paramsInfo”: “”
    },
    “$type”: “NodeCanvas.Framework.Internal.ReflectedFunction
    1[[System.Collections.IEnumerator, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]”
    },
    “_isActive”: true,
    “overrideAgent”: null,
    “$type”: “NodeCanvas.Tasks.Actions.ExecuteFunction”
    }
    ],
    “_isActive”: true,
    “overrideAgent”: null
    },
    “_repeatStateActions”: false,
    “_transitionEvaluation”: “CheckContinuously”,
    “_collapsed”: false,
    “_position”: {
    “x”: 5835.0,
    “y”: 5370.0
    },
    “_name”: “sdfsdf”,
    “_tag”: null,
    “_comment”: null,
    “_isBreakpoint”: false,
    “$type”: “NodeCanvas.StateMachines.ActionState”,
    “$id”: “11”
    }
    ],
    “connections”: [
    {
    “_condition”: null,
    “_infoExpanded”: true,
    “_sourceNode”: {
    “$ref”: “1”
    },
    “_targetNode”: {
    “$ref”: “5”
    },
    “_isActive”: true,
    “$type”: “NodeCanvas.StateMachines.FSMConnection”
    },
    {
    “_condition”: {
    “targetType”: “TestScript”,
    “eventName”: “Docked”,
    “_invert”: false,
    “_isActive”: true,
    “overrideAgent”: null,
    “$type”: “NodeCanvas.Tasks.Conditions.CheckCSharpEvent”
    },
    “_infoExpanded”: true,
    “_sourceNode”: {
    “$ref”: “5”
    },
    “_targetNode”: {
    “$ref”: “11”
    },
    “_isActive”: true,
    “$type”: “NodeCanvas.StateMachines.FSMConnection”
    },
    {
    “_condition”: {
    “targetType”: “TestScript”,
    “eventName”: “UnDocked”,
    “_invert”: false,
    “_isActive”: true,
    “overrideAgent”: null,
    “$type”: “NodeCanvas.Tasks.Conditions.CheckCSharpEvent”
    },
    “_infoExpanded”: true,
    “_sourceNode”: {
    “$ref”: “11”
    },
    “_targetNode”: {
    “$ref”: “5”
    },
    “_isActive”: true,
    “$type”: “NodeCanvas.StateMachines.FSMConnection”
    }
    ],
    “primeNode”: {
    “$ref”: “1”
    },
    “canvasGroups”: null,
    “localBlackboard”: {
    “_name”: “Local Blackboard”,
    “_variables”: [],
    “$type”: “NodeCanvas.Framework.Internal.BlackboardSource”
    }
    }