- Modifié
[Unity] Mecanim now supported in Unity 4 and 5!
I just pushed a new class, SkeletonAnimator, up to the git repo and updated the unitypackage. 8)
Mecanim is now fully supported by the new SkeletonAnimator (derived from SkeletonRenderer). SkeletonAnimation is still around, but you now have the option of clicking the Generate Mecanim Controller button to create a controller with dummy-animation clips which will keep itself updated with the SkeletonDataAsset when changes are detected.
There's a new context menu if you right click a SkeletonDataAsset in project view under Spine> called Instantiate (Mecanim) - this will handle all of the setup process automagically.
SkeletonUtility and all of its friends are fully compatible with SkeletonAnimator as well.
Events have the same limitation of the native Unity baking process in that they only support 1 data type at a time in the order of preference String, Float (or int), No Arguments.
Also took a pass at Unity 5 compatibility which should be all cleaned up now.
Test the crap out of this please :notme:
Never! I'll NEVER use Mecanim!
But I will use Unity 5, because according to the Release Notes:
AudioClip now supports multi selection and editing, so you no longer have to change the same property on all clips one by one, just select all the clips you want to change and get it over with all at once.
Thanks Mitch for your great work. :-) This is going to be fun creative life with spine and your runtime :-)
I have never used mecanim, is it any idea to switch? Any advanteges? (I see @Pharan doesn't seem to think so )
@davidsvson.
There are a lot advantages. Mostly ease of setup, without having to code animation controllers yourself, especially for fun things like blend trees.
I like to roll my own though 'cause sometimes it's hard to get Mecanim to do what you want. Mecanim was really made with 3D animation in mind, whereas I personally like to handle my Spine animations like PlayStation-era 2D sprites.
If Mecanim is what you're used to, it's definitely a good thing to have.
If you've never used Mecanim before, expect to spend some time watching videos and searching how-tos to learn how to use it, as with any part of Unity.
Mitch, you're the man, and you know it.
@davidsvson I concur with Pharan. For instance, I'm currently working on a 2D point and click adventure using Spine. Mecanim is not as suited for this since in our case things as speed or velocity to determine animation states are not fundamental.
Mitch showed it tome using one of his platformer examples though, and you'll find it's perfect for those cases.
Thanks @Mitch @Pharan and @wrongtarget!
I'll not convert to mecanim in my current project but will try it out for the next one.
Great news! I'm seeing a lot of glitches though with Unity 5.
For testing purposes, I moved a character to a Mecanim state machine (previously setting/mixing clips in code).
I have a non-interruptible transition to a state (player turns from right to left), which then transitions (non-interruptible) to "idle" at normalized Exit Time 1.0 (no other conditions). This animation is not played entirely, it often ends up with frames half-way in the turning movement, as if leaving too early
Flipping the skeleton is erratic as well. I can use either
transform.rotation = Quaternion.AngleAxis(facing < 0 ? 180 : 0, Vector3.up);
or
GetComponent<SkeletonAnimator>().skeleton.FlipX = facing < 0;
to flip the skeleton for all left-facing states. It was working before moving to Mecanim, but now it's erratic. Almost seems as if the state machine is messing with the FlipX state of the skeleton (or is it the root bone transform / both?)
Thanks
Rouven
There is a parameter called Mix Mode on the skeleton animator that controls how mixing is applied per mecanim layer. Try setting it to SpineStyle and see if that resolves your issue.
You have no idea how much this helped our workflow when trying to figure out how to sync animations in Bolt networking. Bolt has mecanim support which automagically sync's everything so adding this basically made our day x 500.
Lifesaver.
I'm pretty new to Spine, and I'm having trouble figuring things out. I've tried the Generate Mecanim Controller thing, but I'm not sure how to use it.
So far I was using the "bake all skins" button, which worked fine, I then created a new animator that used the animations from the ones from the bake. It was fine, except that I had to bake stuff again everytime I changed something.
I've tried "Generating Mecanim Controller", and assigning that generated controller to my baked prefab, but it doesn't seem to work. What am I missing ?
@Mitch That didn't change anything, unfortunately. I have disabled and even removed my second (upper body) layer in the Animator, but the issues persist within the Base Layer.
I just noticed the keys that are dropped are only those that attach an image to a slot. All Scale/Rotate/Translate keyframes are applied just fine.
Baking and Generate Mecanim Controller are unrelated. The SkeletonAnimator class acts an interface between mecanim and SkeletonRenderer so it is fundamentally different than baking.
Rouven a écrit@[supprimé] That didn't change anything, unfortunately. I have disabled and even removed my second (upper body) layer in the Animator, but the issues persist within the Base Layer.
I just noticed the keys that are dropped are only those that attach an image to a slot. All Scale/Rotate/Translate keyframes are applied just fine.
Would you be willing to send me your exported files w a controller that exhibits this issue? Would love to poke at it heh
Sure, just PM me your email address!
This looks amazing! Will these features be included in the tk2d runtime aswell?
I don't think there's any difference between them in regard to mecanim. Try bringing the animator scripts over.
It worked, thanks
Would love to see this in the official runtime tho, no pressure
Gisle a écritIt worked, thanks
Would love to see this in the official runtime tho, no pressure
Yea; I owe the TK2D runtimes some updates heh. I never use TK2D though not like I get paid for this :wonder: