- Home /
New Animation clip blocks player rotation
Hi!
I have a prefab gameobject with a playermovement script and it has a flip function below. The function works fine and I have had a few animation clips on it for some time. However, recently I tried adding a new clip with keyframes that adjusts the player's rotation in a while that makes it look like it is spinning.
After making this new clip, my character no longer flips. I tried removing all the keyframes in my animation clip and it went back to normal. Is there any reason why adding a new animation clip would block my player from flipping?
Any help would be really appreciated as I am quite new to Unity!
Thanks
private void flip()
{
facingRight = !facingRight; // updates facing direction
Vector3 flipped = transform.localScale;
flipped.z *= -1f;
transform.localScale = flipped;
transform.Rotate(0, 180, 0);
}
Answer by HappyPixel27 · Jul 03, 2020 at 12:46 AM
Make sure to stop the animator from continuing the animation. that way the player can resume control of the player object.
One way you could do this is to remove the animation clip after it has been completed.
Answer by Pkmans · Jul 03, 2020 at 04:06 PM
Okay I never found out what the actual underlying bug was, but a fix that I did was just to change my animation clip from changing the player's rotation, to changing the player's X-axis scale instead. This seems to save solved the problem at least for now.
Your answer
Follow this Question
Related Questions
Why is Unity always adding some strange Transformations? 0 Answers
Unity rotation bug??? or my mistake (with video) 1 Answer
Unity not playing Legacy animation 0 Answers
Input Text Rotated incorrectly... is this a BUG? 1 Answer
Animated Sprite Rotating Around It's Own Axis Instead Of Parent's Using Script. Details Provided. 0 Answers