Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: celaeno on March 10, 2016, 07:18:28 AM

Title: Error using StartCoroutine() within action[WONTFIX]
Post by: celaeno 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
   }
 }





Title: Re: Error using StartCoroutine() within action
Post by: jeanfabre 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
Title: Re: Error using StartCoroutine() within action
Post by: celaeno on March 10, 2016, 01:22:34 PM
Oke thanks for your help  :)