'Coordinate the animator with the clip's filp
I make my character turn on himself. To save money I only have the sprites where he looks left and not right. I flip the animation so that he looks to the right.
To activate the action look left I change the Integer in the animator that defines the orientation. And for the filp I do it on the spriteRenderer. My problem is that the 2 are not done at the same time, so between the moment he looks right and left, he looks in front and at a moment the front image is flipped before he looks right, it makes an absolutely horrible effect in my game.
How do I get the flip to happen at the exact same time as the animation changes?
IEnumerator updateOrientation()
{
yield return new WaitForEndOfFrame();
int orientationAnimation;
if(angle<45 && angle>=-45)
{
orientationAnimation=FACE; //"face";
orientationActuelle="face";
spriteRenderer.flipX=false;
}
else if(angle<-45)
{
orientationAnimation=LEFT; //"right";
orientationActuelle="right";
spriteRenderer.flipX=true;
}
else if(angle>=45)
{
orientationAnimation=LEFT; //"left";
orientationActuelle="left";
spriteRenderer.flipX=false;
}
animator.SetInteger("orientation_animation",orientationAnimation);
yield break;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
