What line is the actual error on because this isn't where the problem lies. WaitForAnim takes 1 argument (anim) but you've used it—somewhere—without placing an anim parameter.
-
WaitForAnim takes 0 arguments means you are calling the Coroutine without placing a variable for the anim parameter
StartCoroutine( WaitForAnim() );
should be
StartCoroutine( WaitForAnim( animator ) );
I changed the variable *anim* to animator because your argument is also named *anim*.
-
Not sure if this is just a snippet because I don't see the anim parameter being used inside the coroutine. Instead of using GetComponent why not reference the animation component instead?
Animator anim;
void Start()
{
anim = GetComponent ();
}
IEnumerator WaitForAnim(Animator anim)
{
while (GetComponent().isPlaying == true)
{
yield return new WaitForSeconds (1);
}
}
to this:
Animator animator;
Animation animation;
void Start()
{
animator = GetComponent();
animation = GetComponent();
}
IEnumerator WaitForAnim( Animator curAnimator, Animation curAnimation )
{
while ( curAnimation.isPlaying )
{
yield return new WaitForSeconds( 1 );
}
}
-
Now, you have to call the coroutine differently:
StartCoroutine( WaitForAnim( animator, animation ) );
-
Also, waiting for a second each check may result in waiting well after the animation is finshed. May be better to wait every frame instead...
↧