On this subject. You could build a "breaking" WaitForSeconds. See the attached code. Also, this code demonstrates the Coroutines, and feeding functions as variables.. and it works Code (csharp): function Awake(){ StartCoroutine(UselessCoroutine()); } function UselessCoroutine(){ yield(WaitForSecondsX(1.5, testEvent)); print("Done"); } function WaitForSecondsX(seconds : float, event){ var breakTime=Time.time + seconds; while(Time.time<breakTime){ yield; if(event())return; } } function testEvent(){ return transform.position==Vector3.zero; }
with my script when yield return new waitforsecends() complete then my animation fade to idle animation. i want if state changed in waiting time then break yield and change animation to idle. thankful.