Hi is there any chance we can see the new animation property names?
So far I have
localEulerAnglesRaw.x
m_LocalRotation.w
previously m_LocalRotation used to be localRotation
Hi is there any chance we can see the new animation property names?
So far I have
localEulerAnglesRaw.x
m_LocalRotation.w
previously m_LocalRotation used to be localRotation
I’d like to know the euler property names too please. localEulerAnglesRaw.x didn’t work for me.
EDIT: To add a little more information. I’m trying to use clip.SetCurve(…) with the new beta euler curve property for rotation.
TL;DR: In 5.3 and onwards, use AnimationClip.SetCurve as much as possible
AnimationClip.SetCurve:
AnimationUtility.SetEditorCurve:
localEulerAngles / m_LocalEulerAngles Euler keys, Quaternion results
localEulerAnglesBaked / m_LocalEulerAnglesBaked Euler keys, Quaternion results that try to look like Euler
localEulerAnglesRaw / m_LocalEulerAnglesRaw Euler keys, Euler results (5.3 and onwards)
Don’t use localRotation with AnimationUtility.SetEditorCurve, use AnimationClip.SetCurve instead
Long version
I’ll give the long explanation here for posterity’s sake.
For transform properties, both local<Rotation/Position/Scale> and m_Local<Rotation/Position/Scale> are supported, and you should probably support both if you read/write to those curves.
For transform bindings (local<Rotation/Position/Scale> / m_Local<Rotation/Position/Scale>), there are two types of bindings; Vector and Quaternion.
Quaternions are split into 4 float curves: x,y,z,w.
Vectors are split into 3 float curves: x,y,z,w.
Position and Scale are Vectors, so they have x,y and z. Rotation is a Quaternion, so it x,y,z and w.
Those curves are named m_Local<Rotation/Position/Scale> because they map directly to serialized properties of the Transform that have those actual names. local<Rotation/Position/Scale> is just an alias
If you use AnimationClip.SetCurve, you can use those names, plus the appropriate suffixes(x,y,z,w) to create curves in your clip.
In 5.3, we added a new property; m_LocalEuler / localEuler. I follows the naming convention that the other curves use, but it doesn’t map directly to a serialized property.
m_LocalEuler is a Vector3 (x,y,z), and you can also use it with AnimationClip.SetCurve to create an EulerCurve that is equivalent to animating transform.localEulerAngles.
Before 5.3, if you wanted to add Euler keyframes to an AnimationClip, you had to use AnimationUtility.SetEditorCurve with special bindings. In 5.3, you should be able to do everything directly in AnimationClip.SetCurve.
We strongly suggest you directly use AnimationClip.SetCurve in 5.3. It should greatly simplify any existing code, minimize chances that changes we do for the AnimationWindow breaks your tools, and give better results.
However, here’s a rundown of how AnimationUtility.SetEditorCurve works:
Since editing quaternion curves is not really interesting, in the AnimationWindow we use AnimationUtility.SetEditorCurve to set special bindings that simplify working with rotation curves. Those bindings never make it to runtime, and are only used to simplify our work in the AnimationWindow.
The following rotation properties are available through AnimationUtility.SetEditorCurve:
localEulerAngles (x,y,z) (unchanged from 5.2)
Used by the Quaternion interpolation mode. Euler keyframes, translates to a quaternion curve. Affects m_LocalRotation
localEulerAnglesBaked(x,y,z) (unchanged from 5.2)
Used by the Euler Angles(Quaternion Approximation) mode. Euler keyframes, translates to a baked quaternion curve that approximates euler interpolation between user-supplied keyframes. Affects m_LocalRotation
localEulerAnglesRaw(x,y,z) (new in 5.3)
Used by the Euler Angles interpolation mode. Euler keyframes, euler curve. This is evaluated as an euler curve up until it has to be written into the rotation of the object. Affects m_LocalEuler
Those three bindings also have a m_ version that you will probably want to support
Beware: You can’t mix and match these types. If you want to write to one of these, you need to set all the others to null. Doing otherwise will give you errors.
This means that you can’t set localEulerAngles.y if you have any curve on localEulerAnglesRaw. You need to clear all the localEulerAnglesRaw first.
Finally, there is also one quaternion binding that you can use, but we strongly suggest that you directly use AnimationClip.SetCurve for this one, because it’s used in conjunction with the three euler bindings, and trying to manage this without access to the underlying code will be a nightmare. Use AnimationClip.SetCurve instead.
Changing any of those editor curves (through AnimationUtility.SetEditorCurve) will cause changes in the underlying curves to which they map, and changing the underlying curves (through AnimationClip.SetCurve) will cause changes to those curves.
That is a fantastic answer. I can’t ask for anything else - thank you very much @DavidGeoffroy .
Glad I could help. Feel free to reply here if you get issues with this. We don’t have many users who use this, and since it’s mostly used internally, it’s really underdocumented.
I hate to say it but I am actually getting issues. To give some context, I’m writing a Collada importer in managed c# code. I’m dealing with animation curves from the import.
After processing my curves I do the final…
clip.SetCurve(key, typeof(Transform), "localEuler.x", xRotCurveFinal);
clip.SetCurve(key, typeof(Transform), "localEuler.y", yRotCurveFinal);
clip.SetCurve(key, typeof(Transform), "localEuler.z", zRotCurveFinal);
When checking my animation, it doesn’t seem valid (it doesn’t run). I do see the curve in the animation window when debugging in Unity Editor though but the animation won’t play.
If I use the following code…
clip.SetCurve(key, typeof(Transform), "localRotation.x", xRotCurveFinal);
clip.SetCurve(key, typeof(Transform), "localRotation.y", yRotCurveFinal);
clip.SetCurve(key, typeof(Transform), "localRotation.z", zRotCurveFinal);
clip.SetCurve(key, typeof(Transform), "localRotation.w", wRotCurveFinal);
the animation works (but at this point I’m having my own code issues so I’d like to use ‘localEuler’ for rotation as it would make my life a lot easier).
Any suggestions? Am I doing something wrong?
EDIT: Just to confirm, for the first code example I’m using Euler curves and when I try the second code block I convert the Euler into Quaternions and build Quaternion curves so, at least from my understanding, what I’m doing should work with ‘localEuler’.
EDIT2: I only ever use AnimationClip.SetCurve as the mod tool I’m developing is runtime / UnityEngine only (not Editor time).
Also a change from Unity 5.2.2 I noticed is that the curves now seem to show in the Animation window upside down. The curve used to be positive and now the same curve is negative values. Has this been seen before?
When checking my animation, it doesn't seem valid (it doesn't run). I do see the curve in the animation window when debugging in Unity Editor though but the animation won't play.
Hmm… it’s probably broken in Legacy. I’ll see what I can do about a patch for that. We try to modify Legacy as little as possible (because it’s going to be deprecated soon™)
It should work in Editor for humanoid and generic though. (Not that this helps you much)
An alternative to Legacy I suggested to someone working at BigCompanyX is:
You could offload this to a server farm (Amazon, Azure, your own), send the collada file, run the editor in command line on the server, and return an assetBundle. But unless you plan to sell this feature, that’s not viable.
Also a change from Unity 5.2.2 I noticed is that the curves now seem to show in the Animation window upside down. The curve used to be positive and now the same curve is negative values. Has this been seen before?
The evaluation of Quaternion to euler has changed a bit in the alpha/beta. Normally, the values should be equivalent (-30 vs 330), but it might be a bug. If it’s a problem, please file a bug with a small repro case, paste it here and I’ll check it out.
I’ll check it right away, because I’d rather iron out those bugs early on.
I am using Legacy so it’s possible if you say it may be a problem there. Any work to fixing it would be great and much appreciated.
We would love to eventually move over to non-Legacy / Mecanim but the runtime / UnityEngine time support for end-to-end script-only Mecanim wasn’t where we needed it last time we looked. We need full runtime script access to creating state machines, re-targeting and avatar creation (among other things). This would allow game modders to set up their own animation workflow / transitions using our dedicated, and bundled, mod tool.
The suggestion you gave about offloading the model import to a server farm is an interesting one but one I’m not sure would work well for our use case (and since we don’t plan to charge for mod support / tools it would become cost prohibitive).
If the animation graph isn’t technically wrong I wouldn’t call it a problem on my end. We only use the unity Animation window to confirm the animation is in there when debugging the importer. It tends to show the curves differently to Maya anyway so it may be something we just get used to. I can try to raise a case against it anyway just in case if you need it to investigate. Trying to make a small project might prove a little tricky due to the model import code being substantial in size, as you can imagine.
A lot of this should be possible as of 5.2 via the Playables API (and runtime avatar creation has been possible for a while, via UnityEngine.AvatarBuilder). You should check it out!
Really? That sounds exciting! Thanks for the heads up, @superpig :).
When I last checked about avatar creation it was Editor only so will look into that as well.
The fix for Eulers in Legacy is done.
It’ll get patched in soon™
That was awesomely quick. Thank you so much =).