- Home /
Scale animation doubt
Recently I have found some abnormal behaviour while working with Unity Animator. I am working with this engine from pretty long time. Whether it is normal behaviour or mistake I don't know. So I want some information related to this.
For my 2d game, I have created alpha and scaling animation for my sprite. The animation worked as expected. Moving my main player on left and right direction I have used following code. That is not working after applying animation to player object.
void Update ()
{
if (!GameManager.Instance.IsGameOver) {
// desktop
if (Input.GetKey (KeyCode.LeftArrow)) {
Vector3 fishScale = transform.localScale;
if (fishScale.x < 0) {
fishScale.x *= -1.0f;
transform.localScale = fishScale;
}
rigidbody2D.AddForce (Vector2.right * -force);
} else if (Input.GetKey (KeyCode.RightArrow)) {
Vector3 fishScale = transform.localScale;
if (fishScale.x > 0) {
fishScale.x *= -1.0f;
transform.localScale = fishScale;
}
rigidbody2D.AddForce (Vector2.right * force);
}
}
}
I have flipped same sprite using scale to reuse same image. My player animator controller look like following
Here, FadeAwayDeath state play scale and alpha animation. Basically normal blend tree animation working when GameOver and "FishHeath" variables reach at some value become enable and plays FadeAwayDeath animation.
But in this I found that, when scale animation attached to animation my fish flipping not worked. It work on only alpha animation. At start of game, there is effect of scaling variable so using script flipping not worked at all. I have checked for activation of this state but at that time it is not active though it is applying its effect.
When value reached at target state then it plays FadeAwayDeath animation normally. I tried to understand my problem as best as possible from my side. Event though you don't understand then let me know about it.
I want your valuable suggestions here.
would you please inform what are the setting in Animator Component of the Object? like Apply root motion & Animate Physics.
Your answer
Follow this Question
Related Questions
I can't record an animation for my player model 0 Answers
Changing the size of an animated 2D object 0 Answers
2D Animations Scaling Away From The Floor 0 Answers
4.3 messing the animations 3 Answers