Hello, I'm converting my project from JS to C# and I believe this is the very last of the hundreds of errors I had to resolve in the process. I'm receiving the error "StartCoroutine' does not exist in the current context " on line 312.
In method:
public void OnControllerColliderHit(ControllerColliderHit hit)
{
[...]
component = gameObj.GetComponent("MovementReverse");
if(component != null)
{
MovementReverse handler;
handler = component as MovementReverse;
StartCoroutine(MovementReverse(handler)); // line 312 with the trouble
}
[...]
}
This is within my BlobController class:
[RequireComponent(typeof (CharacterController))]
public class BlobController : Component
And my file has the standard usings:
using UnityEngine;
using System.Collections;
Oddly, StartCoroutine appears in the intellisense in MonoDevelop as a method, however when typing the parenthesis '(' it doesn't display the typical box to let you know what arguments are required, which seems to imply that some library isn't properly referenced or something, however even the reference in the Unity manual doesn't have any additional using statements.
http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.StartCoroutine.html?from=index http://unity3d.com/support/documentation/ScriptReference/index.Coroutines_26_Yield.html
In addition, I've tried all of these lines, none work:
StartCoroutine(MovementReverse(handler));
yield return StartCoroutine(MovementReverse(handler)); // changed method return type to IEnumerator
StartCoroutine(new MovementReverse(handler));
yield return StartCoroutine(new MovementReverse(handler));
Am I doing it wrong? I'm stumped.
Edit 1: Here's the coroutine I'm calling:
public IEnumerator MovementReverse(MovementReverse handler)
{
// stop blob from moving
StopMoving();
// wait, will resume this public void at this spot after 1 second
yield return new WaitForSeconds(handler.delayBeforeReversing);
[...]
}
According to the reference and some blog posts, this appears to be correct, what is going wrong?