We’ve been having an issue where some animations exported from 3ds Max (exporter version v20220401.2) and imported into Unity (with a custom importer) glitch seemingly randomly on rotating objects. As an example, this is a test object of a simple pendulum swinging back and forth (Time.timeScale
set to 0.1 to more clearly show the issue):
For reference, this is the source animation in 3ds Max:
In investigating this, I extracted the keyframe data and plotted it on a graph.
As you can see, when the w component passes 0.5, both the x and w components flip to negative, then back to positive when w passes -0.5 again. Because Unity is interpolating between the values before and after the flip, it causes the object to rapidly (over just a couple of frames) spin through 360 degrees.
If I go into the exported GLB and manually change all the negative values back into positive, this does fix the glitch:
To further complicate the issue, this flipping doesn’t seem to consistently happen. In another test, we have 3 spheres with each rotating 360 degrees around a different cardinal local axis. The resulting GLB’s all exhibit the same basic behaviour, but at slightly different times despite w component of the rotation being effectively identical, and only at one of the instances of crossing 0.5:
This seems to me to be a bug in the exporter, and even seems to be something covered in the glTF specification (glTF 2.0 Specification - Cubic Interpolation), albeit in relation to actual cubic keyframes as opposed to the way the exporter bakes the animation down to linear keyframes.