Hey, no worries! Really good of you to look at it at all to be honest. And congrats to your brother!
Agreed, the Spine runtime is super complex – at least to me. I’ve mostly just worked around the limitations. In general I’m using their AnimationState to control animations, it’s just occasionally when I want precise control that I use Slate.
The only thing that gets weird is the blending from one animation to another (and avoiding blending back to the root pose). If I only have one animation on the timeline, it’s all good.
Ah, great. Yeah, I don’t use that feature, so I’ll just stick with your original suggestion.
Thanks!
Update: Unfortunately I’m still getting problems with odd mixing behaviour.
Back to the drawing board…
Hi Gavalakis,
Made some progress on this. A user on the Spine Forums called Boboshu posted some code that seems to get animation blending working. Posting here for your reference – hope that’s ok. This is the change to the UpdateClip method:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
public void UpdateClip(PlaySpineAnimationClip clip, float time, float previousTime, float weight){ if (spineComponent != null){ //baseWeight = activeClips == 2? 0 : 1 - weight; //clip.clipAnimation.Apply(skeleton, 0, time, true, null, weight * this._weight, Spine.MixPose.CurrentLayered, Spine.MixDirection.In); //fix spine 3.6 mix bug 2018.9.16 //by boboshu if( skeletonAnimation == null) skeletonAnimation = spineComponent as SkeletonAnimation; var toAnimation = clip.clipAnimation; // Approximate what AnimationState might do at runtime. if (activeClips > 1 && fromAnimation != null) { skeleton.SetToSetupPose(); fromAnimation.Apply(skeleton, 0, fromTime, true, null, fromWeight, MixPose.Setup, MixDirection.Out); toAnimation.Apply(skeleton, 0, time, true, null, weight, MixPose.Current, MixDirection.In); } else { skeleton.SetToSetupPose(); toAnimation.PoseSkeleton(skeleton, time, true); } fromAnimation = clip.clipAnimation; fromTime = time; fromWeight = weight; } } |
Also need to add these variables:
1 2 3 4 5 6 7 8 9 10 11 |
[System.NonSerialized] private SkeletonAnimation skeletonAnimation; [System.NonSerialized] private Spine.Animation fromAnimation; [System.NonSerialized] private float fromTime; [System.NonSerialized] private float fromWeight; |
and in OnInitialize()
skeletonAnimation = actor.GetComponent<SkeletonAnimation>();
Link to original post: http://esotericsoftware.com/forum/Unity-Slate-ith-Spine-3-6-mix-bug-please-help-10825
Well I’m not sure what I want to do there 🙂
Can you give me a brief description of what the “active layer” is please?
Ah, thanks!
Perhaps it’d be better to edit the OnSampleEnded method itself and only disable the DirectorGUI if isActive? I presume we still want to RestoreLayersActive and all the other stuff in that method?
1 2 3 4 5 |
void OnSampleEnded(){ RestoreLayersActive(); if(isActive) DirectorGUI.current.enabled = false; //etc... } |
What do you think?
Hey Gavalakis,
Did you get round to checking out the 3.6 Spine runtime to see if you could update the Spine Track extension? I made a similar fix to cagezero who posted above, but seeing the same odd behaviour when trying to blend between animations.
Thanks!
Ah thanks 🙂
Have ported the change back to my version (need to stick because I’ve modified stuff)
Hi Gavalakis,
Thanks for confirming.
The reason I’m doing it this way is because the cutscene is already running (and looping). At a certain point in the game I want the cutscene to finish its current loop and stop. I can’t do that with the Play() method, as if the cutscene is already playing, the method returns early, before changing the wrap mode. Likewise, DefaultWrapMode won’t work since the cutscene is playing already.
Thanks!
Ben