playMaker

Author Topic: Error using StartCoroutine() within action[WONTFIX]  (Read 1634 times)

celaeno

  • Playmaker Newbie
  • *
  • Posts: 7
Error using StartCoroutine() within action[WONTFIX]
« on: March 10, 2016, 07:18:28 AM »
Hello I get this error when using StartCoroutine()

Quote
Assets/PlayMaker/Actions/Puzzle Game/FindNeighbours.cs(126,33): error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected

Is it possible or how can I use StartCoroutine() within an action?

Thanks


Code: [Select]
using UnityEngine;
using System.Collections;
using System.Collections.Generic;


public class FindNeighbours : FsmStateAction


   public override void OnEnter()
     Debug.Log ("About to StartCoroutine");
     StartCoroutine(TestCoroutine());
     Debug.Log ("Back from StartCoroutine");
   }
   IEnumerator TestCoroutine(){
     Debug.Log ("about to yield return WaitForSeconds(1)");
     yield return new WaitForSeconds(1);
     Debug.Log ("Just waited 1 second");
     yield return new WaitForSeconds(1);
     Debug.Log ("Just waited another second");
     yield break;
     Debug.Log ("You'll never see this"); // produces a dead code warning
   }
 }





« Last Edit: March 25, 2016, 02:39:15 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Error using StartCoroutine() within action
« Reply #1 on: March 10, 2016, 08:17:28 AM »
Hi,

 Unfortunatly no, because an action is not a MonoBehavior it doesn't implement the internal necessary apis for coroutine to be executed and handled properly.

Typically, either you create your custom coroutine system ( like you would when creating editor windows and tools, which also lack coroutines), or you save the Ienumerator of the function you want to "coroute" and handle it manually.

Bye,

 Jean

celaeno

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Error using StartCoroutine() within action
« Reply #2 on: March 10, 2016, 01:22:34 PM »
Oke thanks for your help  :)