Animation Goes Crazy When I make keys

When I’m trying to animate an object, i start with frame 1 blank, then i go to the 0.10 mark and slight move it, then when i play it it goes super crazy and i just want to know how to fix it??

Hi, I ran into a similar problem recently and here’s how I fixed it. I noticed that the “going crazy” was due to adding a rotation to the object in the animation; specifically, when the rotation was in negative degrees. For example, if you set the rotation in the x axis as -10, unity will change it to 350, so the animation will go to the specified position the “long way”, causing the craziness.

To solve this, go into the curves tab in the animation window and find the key with the wrongly converted number (in this case, it would be the key with the 350 value under the x axis rotation). Right click on the key and select edit key. Then, change the value from 350 to -10. This time, Unity won’t change the number and your animation will work properly. Do this for all the keys whose values are being wrongfully converted.

Hi guys, can you tell us in which version you are getting this?

it look like a bug we did fix a few week ago

This is the bug in question:

It is fixed in 5.3.6

I’m running 5.3.5, so I guess I’ll have to upgrade and see if that fixes it

If your bug is still happening in 5.3.6, please file a bug. This is a serious issue, and I’d like to make sure it stays fixed.

If this is not filed yet I can confirm it is still happening in 5.4.0f3 as well. I am copying and pasting rotations via script while editing keys and it doesn’t go into the negative range. I have to manually go in and change all the keys in the curves editor.

2770215--200261--RotationBug.gif

@playemgames
Please file a bug with your script. The Animation Window does quite a few propgrammatic backflips to deal with the fact that the transform doesn’t actually store Euler angles, only quaternions. Interacting with the recording by script (as opposed to creating your own curves) is quite finnicky, so I’d like to take a look at your script to see exactly is going wrong.

Sure thing will submit one later today.

@DavidGeoffroy I privated messaged you the case number, let me know if you have any questions. I also found a bug where if you copy and paste rotation animation keys between animation clips they are always Quaternion Interpolation neglecting the source interpolation of the keys.

Did this get looked at yet? Really want this fixed so I don’t have to double back and manually set keys to negative all the time in the curve editor.

Transform.localEulerAngles has been changed so the behaviour is coherent between runtime and editor, and will always directly use the Quaternion to set/get angles (what was happening in standalone). This also means that transform.localEulerAngles and transform.localRotation.eulerAngles now return the same value / have the same behaviour.

This also let us fix a bunch of old bugs where when you were rotating an object, rotation values would slowly creep up or jump in weird ways.

We understand that this can be problematic for users who have their own custom keyframing workflows, and we’re adding new accessors to make this work properly.

In the meantime, you can use methods in the file I’ve attached to do the same thing we do in the AnimationWindow:

You need to do something like:
transform.localEulerAngles = yourAngles; //This sets the rotation Quaternion on the GameObject
LocalEulerHint.SetLocalEulerAngleHintOnGameObject(transform.gameObject, yourAngles) //This tells the inspector (and the AnimationWindow) how many rotations to show for this angle

When getting the angle, you don’t need both, you can use LocalEulerHint.GetLocalEulerAngleHintFromGameObject(transform.gameObject)

2795136–202736–LocalEulerAngleHint.cs (1.06 KB)

This is great news! Hopefully all my animation rotation woes will disappear soon then. Are these functions preliminary and undocumented? This explains a lot of discrepancies in the rotations I was having in my animations as I was creating them in Unity.

So if I am going to use a function to set the rotation key or curve in the Animation Window I would use:

LocalEulerAngleHint.SetLocalEulerAngleHintOnGameObject(transform.gameObject, transform.localEulerAngles);

This should match up with what I see in the inspector correct?

EDIT: Actually I see you are referring to the attached script, I imagine this has to be placed somewhere and then used to make the expected behaviors to happen. I also tried to use it and getting a “ArgumentException: failed to convert parameters” error when I test. What version has the new fixes to the rotations?

Oops. I implemented this on the latest version, and I was in a hurry, and forgot to test it in earlier versions.

What version are you on?

5.4.1p1

I have same problem … I set rotation to 90 degrees in my animation … it automatically changes to some random number and animation goes crazy

2018.3 tambien lo hace.

This thread is very old.
If you have bugs related to this, please file a bug. It’s unlikely to be the same bug as this one