• Runtimes
  • [Unity] Mecanim now supported in Unity 4 and 5!

Related Discussions
...

@controllerPath fix
good catch - I missed that i wasn't updating the path string. (I don't move stuff around much heh)

@AttachmentTimeline patch
removing that line adds a lot of overhead. I'm considering creating a list of known patches/workarounds for issues w/ Mecanim and for Spine Unity in general that people can cherry pick and apply, but really have no business being in the main repo.

Hey I'm glad I could help.

Yeah I thought that line was a necessary optimization. The problem is that the way time and lasttime are calculated in SkeletonAnimator leaves gaps. So lasttime is not the actual last time value used in Spine, but slightly after.

If a key falls in the gap between the last time value, and the current lasttime value, that line drops it. I'm sure it can be solved without removing the optimization. I'll try simply storing it for one frame and using the value next frame.

Regards,
Hadi

Ah holy crap I never pushed that patch O_O

I fixed the lastTime calculation a while back. I'll deal with that a bit later. Sorry. Shows how much I use mecanim for anything ... 😐

2 ans plus tard
Mitch a écrit

Ah holy crap I never pushed that patch O_O

I fixed the lastTime calculation a while back. I'll deal with that a bit later. Sorry. Shows how much I use mecanim for anything ... 😐

@Mitch I've got the latest versions of spine-csharp & spine-unity.
But I don't see 'Instantiate' when I right click on SkeletonDataAsset.
Has something changed?

Pharan a écrit

Hello! This is a two year old thread.
This is the new way to instantiate: http://esotericsoftware.com/forum/New-Feature-Drag-and-Drop-to-instantiate-6789

Thanks for the redirection!
I'm kind of not getting the most current workflow to utilize mecanim atm which gets me undesired results when

using UnityEngine;
using System.Collections;
using Spine.Unity;

public class SpineAnimationBehaviour : StateMachineBehaviour
{
    public string animClip;
    public int layer = 0;
    public float timeScale = 1f;
    private float normalizedTime;
    public float exitTime = .85f;
    public bool loop;

private SkeletonAnimation skeletonAnimation;
private Spine.AnimationState spineAnimationState;
private Spine.TrackEntry trackEntry;

override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
    if (skeletonAnimation == null)
    {
        skeletonAnimation = animator.GetComponentInChildren<SkeletonAnimation>();
        spineAnimationState = skeletonAnimation.state;
    }

    trackEntry = spineAnimationState.SetAnimation(layer, animClip, loop);
    trackEntry.TimeScale = timeScale;

    normalizedTime = 0f;
}

override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
    normalizedTime = trackEntry.trackTime / trackEntry.trackEnd;

    if(!loop && normalizedTime >= exitTime)
    {
        animator.SetTrigger("transition");
    }
}

override public void OnStateExit (Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{

}

}

is what is attached to every single clip(as solitary states) in mecanim, therefore I can't really workout the blend tree.
What I want to achieve is just like any other mecanim workflow I'd get to play clips drag & drop without needing such script as above. Is there current workflow?

If you use SkeletonAnimator, you don't need the script above.

When you Instantiate your skeleton as a SkeletonAnimator, a Mecanim controller will be created, as well as several dummy AnimationClip assets as described in this old thread.
You would then lay out your Mecanim controller using the dummy animation clips like normal. Blend trees should work normally.

What SkeletonAnimator is doing at that point is just re-interpreting the state of the Mecanim state machine into poses for the skeleton.

Pharan a écrit

If you use SkeletonAnimator, you don't need the script above.

When you Instantiate your skeleton as a SkeletonAnimator, a Mecanim controller will be created, as well as several dummy AnimationClip assets as described in this old thread.
You would then lay out your Mecanim controller using the dummy animation clips like normal. Blend trees should work normally.

What SkeletonAnimator is doing at that point is just re-interpreting the state of the Mecanim state machine into poses for the skeleton.

Damn, I didn't realize how dated those workflows I followed via Youtube were until this.
I even got my dummy animation clips by clicking the button that generates such.
I think I'd like to re-do the setup following your guide just now and then get back to you for the further question if I get stuck somewhere.
Thnks a lot again!
I think there should be more organized workflow guide as a document, though. If there already is and I just missed it, then it's either I've got dyslexia, or how they were posted were not that popping out because checking out the most recent workflow when it changes by reading forum post isn't the best thing to do such job DX, no offense.

None taken!

The Mecanim controller and dummy animation clips generated by clicking the button on the SkeletonData Asset are the same as when you instantiate the SkeletonAnimator for the first time. There should be no difference.

SkeletonAnimator/Mecanim integration is still less than ideal since Mecanim doesn't have all the necessary callbacks or expose as much of the internal states as we would have liked. This also makes it so that you can't see your skeleton animating in Edit mode, and still requires the dummy animation clips which can be confusing because new users expect there to be editable keys in the animation.

We're actually looking at whether it actually makes more sense to do away with the dummy animation clips and achieve integration via StateMachineBehaviours.

But as it is, SkeletonAnimator should work fine even if it's extensive as long as it's not doing anything that's also hackish.

Pharan a écrit

None taken!

The Mecanim controller and dummy animation clips generated by clicking the button on the SkeletonData Asset are the same as when you instantiate the SkeletonAnimator for the first time. There should be no difference.

SkeletonAnimator/Mecanim integration is still less than ideal since Mecanim doesn't have all the necessary callbacks or expose as much of the internal states as we would have liked. This also makes it so that you can't see your skeleton animating in Edit mode, and still requires the dummy animation clips which can be confusing because new users expect there to be editable keys in the animation.

We're actually looking at whether it actually makes more sense to do away with the dummy animation clips and achieve integration via StateMachineBehaviours.

But as it is, SkeletonAnimator should work fine even if it's extensive as long as it's not doing anything that's also hackish.

If the results are identical either ways why are my clips not played without the script I mentioned above?
What could have gone wrong or done wrong if so?
I'm still not able to play any clips generated by the dummy clips in mecanim though my parameters are working correctly without the behaviour scripts attached to each clip that calls SetAnimation

edit: I found out I need to make 'SkeletonAnimator' not 'SkeletonAnimation. How I set up was with the latter. urgh... I can't tell how much extra work I'd need to to when I start over with SkeletonAnimator...