- Home /
beguin (but not wait for) the smoothing of a float in coroutine
I want to start blending to the next animation but not wait for it to complete.
public override IEnumerator Run2(){
yield return 0;
anim.SetFloat(varName , value , .01f , Time.deltaTime);
}
There is another coroutine calling this one. The problem is that Animator.Setfloat with the dampening time parameter (.01f) only works properly in update. In the above it just goes partway from whereever it is to "value".
background: I am trying to make a behavior tree system. I decided to use coroutines because they make it easier to wait for one task to complete before moving to the next. I put a script on an empty and drag that empty onto the fields of another empty with a script.This is for the "Animation" type node.
Answer by iwaldrop · Jan 08, 2015 at 11:47 PM
First off, if you want the other coroutine to wait for this one, use the yield return keywords before the StartCoroutine method call.
yield return StartCoroutine(SomeCoroutine());
Secondly, you need to loop over the call to set float to accomplish what you describe. Pseudo code:
while(animator float value != target value)
{
SetFloat(...);
yield return null;
}
That will produce a result as if you were doing it in an update loop.
Never $$anonymous$$d about that first part. After reading I notice that you do not want to wait. ;)