Spine Animation Track

Slate Forums Custom Clips Spine Animation Track

Tagged: 

This topic contains 17 replies, has 5 voices, and was last updated by  mografi_ben 3 weeks ago.

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #767

    darkmagicck
    Participant

    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:
    add-spine-animation-track

    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;
    spine-animation-inspector

    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.
    SLATE_SpineAnimationTrack.unitypackageremove.jpg

    Attachments:
    You must be logged in to view attached files.
    #771

    darkmagicck
    Participant

    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:

    
    var reader = new StringReader(textAsset.text);
    var root = Json.Deserialize(reader) as Dictionary<String, Object>;
    if (root == null)
        throw new Exception("Invalid JSON.");
    
    #773

    Gavalakis
    Keymaster

    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! 🙂

    #774

    darkmagicck
    Participant

    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.

    Attachments:
    You must be logged in to view attached files.
    #784

    Gavalakis
    Keymaster

    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! 🙂

    #847

    abuki
    Participant

    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.

    I am working on Dimension Brothers

    #848

    Gavalakis
    Keymaster

    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!

    #849

    abuki
    Participant

    I just tested it quickly and it works. Thank you very much!

    I am working on Dimension Brothers

    #1466

    cagezero
    Participant

    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!

    #1468

    Gavalakis
    Keymaster

    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!

    Attachments:
    You must be logged in to view attached files.
    #1484

    cagezero
    Participant

    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.

    #1491

    Gavalakis
    Keymaster

    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.

    #1778

    mografi_ben
    Participant

    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!

    #1779

    Gavalakis
    Keymaster

    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!

    #1791

    mografi_ben
    Participant

    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:

     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:

    [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

Viewing 15 posts - 1 through 15 (of 18 total)

You must be logged in to reply to this topic.