Hi,
I am coding a Javascript finite state machine based on and adapted from the C# FSM framework found at the unity wiki. I am trying to add a delay so the animation ends before changing to another state but I obtain the next error:
Assets/Scripts/example.js(192,18 ) BCE0101: Return type ‘void’ cannot be used on a generator. Did you mean ‘IEnumerator’? You can also use ‘System.Collections.IEnumerable’ or ‘object’.
The script es called example and it has all the state class implementations (Idle, Run, Turnaround,…)
Any ideas?
Thanks
class Turnaround extends FSMState {
function Turnaround() {
stateId = StateId.turnaround;
}
function Reason(player : GameObject) {
yield player.GetComponent(example).StartCoroutine(player.GetComponent(example).wait(1));
player.GetComponent(example).SetTransition(Transition.turnaroundIdle);
}
function Action(player : GameObject) {
player.GetComponent(example).aniSprite(16, 6, 0, 5, 5, 16);
}
}
function wait(waitTime : float) {
yield WaitForSeconds(waitTime);
}