Forums › 💬 Slate Sequencer › 🤩 Custom Clips › Spine Animation Track
Hi,
Spine is a 2D skeleton solution.
We made the Spine Animation Track to support controlling spine animations.
In order to preview the animation in editor, we changed some of SpineSDK’s codes, so we included Spine’s codes in this package.
You can use the SpineAnimationTrack just like the internal AnimationTrack, which can add clips, set default clip, and control.
How to add spine track:
[attachment file=”add spine animation track.jpg”]
Right click on the track to add clip, edit the clip’s property in inspector:
Note: As for time scale, it’s the clip’s own playback speed. It does not affect Time.timeScale;
[attachment file=”spine animation inspector.jpg”]
Code by StudioGM
(The forum seems unable to add zip or unitypackage attachments)
Download the package in attachments
Remove the name extension to open the unitypackage.
[attachment file=”SLATE_SpineAnimationTrack.unitypackage(remove.jpg).jpg”]
I missed a file called SpineJsonCache which cached the skeleton’s json parsed object in runtime to save reload same skeleton time.
You can just remove the SpineJsonCache code to use original spine’s code.
Keep those lines like this:
|
1 2 3 4 5 6 |
var reader = new StringReader(textAsset.text); var root = Json.Deserialize(reader) as Dictionary<String, Object>; if (root == null) throw new Exception("Invalid JSON."); |
Hello!
That’s awesome of you sharing that! Thanks a lot!
I am downloading to check it out right now.
Regarding the attachments I am sorry for that. I just enabled .unitypackage, .zip and .rar attachements (forgot to do so).
If you want, you can re-upload the package now that the attachments are working correctly 🙂
With your permission, I’d also like to wrap it up and upload it the Downloads sections of the website (along with a link to your post of course). Is that ok with you?
Thanks again! 🙂
Hi, I just made a clean package which reformed the folder structure, and removed the modified json cache codes.
You can simply start a new project, import SLATE, and then import this package to test it out. (Tested under Unity5.4.1f1 with SLATE1.5.0)
I added a small Demo scene Under Assets/ParadoxNotion/SLATE Extension/Spine/Demo/
(By the way I did not see any edit button in my post so I can only upload this package here in reply)
Feel free to share this package, Gavalakis. It’s you who made this awesome Cutscene Tool, Thanks.
Great! Thanks for uploading again and also thanks for your feedback. I am very glad you like Slate 🙂
By the way, I’ve expanded on your extension and made it possible to also work with the original runtimes, as well as support blend in/out and blending between different animations, similar to the Animation/Animator Track 🙂
I will also upload my version once the new Slate version is live (pending review right now), because there are some dependencies with the new changes (which were mostly inspired by the needs I saw you had creating your version)
Thanks again! 🙂
Hello, will you also add support to Skeleton Animator component? I purchased Slate but can’t get the cutscene running, because I am not able to play spine animations and I can’t change from Skeleton Animator to Skeleton Animation.
Hello,
Sorry for the late reply.
I have just updated the Spine extension in the Downloads section to work with both SkeletonAnimation and SkeletonAnimator! 🙂
Let me know if that works well for you.
Cheers!
I just tested it quickly and it works. Thank you very much!
Hi, our team is using SLATE for all our cutscenes and we just ran into a bit of a snag while implementing our Spine animations. The extension for spine comes in with some compile errors, which I was able to quickly patch so that it compiles, but I am seeing some odd behavior when switching between animations. From what I can tell this is due to the introduction of Animation.MixPose and Animation.MixDirection, but I have not done an exhaustive examination. All that just to say that an update to the Spine extension would be much appreciated 🙂
Thanks!
Hello! 🙂
I have attached for you here a new Spine integration .unitypackage (which have not yet made it to the Downloads section), which should work.
MixPose, is basically replaced with Apply completely.
Let me know if the attached Spine integration package works for you correctly now.
( Please make a backup just in case 🙂 )
Thanks!
Thanks Gavalakis! I might be missing something, but this package seems to have the same problem as the previous package. One instance of the problem is on line 103 of the class SpineAnimationTrack.cs:
baseAnimation.Apply(skeleton, 0, scaledTime, true, null, baseWeight * this._weight, false, false);
So far I have converted the Apply method to pass in the appropriate information for the parameters: ‘loop’, ‘pose’, and ‘direction’, but we are still getting some strange behavior when blending between two animations.
Hmm. I must be using an old version of Spine then.
I will check to see if that is the case, and if so, download the latest one and check the integration once again.
Thanks for the heads up.
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!
Hello,
I’m sorry but I totatly omited checkking latest Spine version between all other things.
I will try to do so this week.
Thank you!
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
