Quantcast
Channel: Latest Questions by esitoinatteso
Viewing all articles
Browse latest Browse all 92

StateMachineBehaviour + StartCoroutine()

$
0
0
Hi there! I'd like to know, if it's possible, how to StartCoroutine() inside a StateMachineBehaviour script. I've tried the following: IEnumerator WaitSomeThenResetStuff (Animator anim){ yield return new WaitForSeconds(4f); //Reset stuff anim.ResetTrigger("stuff"); } // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { StartCoroutine(WaitSomeThenResetStuff(animator)); } But " StartCoroutine" is unknown to classes that inherits from StateMachineBehaviour. I thought ( because my knowledge is approssimative) to solve the problem by adding an interface to MonoBehaviour but another error showed up... maybe I made some mistakes or maybe that's not the best approach. I ended up using the StateMachineBehaviour's Update with a clock to do the same thing, caching Time.time inside OnStateEnter(). Thanks for your time!

Viewing all articles
Browse latest Browse all 92

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>