• Runtimes
  • Unity3D and spine transit animations.

Related Discussions
...

Hello! Maybe somebody know about: how in UNITY make transit animations, such as run->jump, static->run->static and other same thing. (.json format)

You can take a look at the example unity project.
In there is a file called Spineboy.cs which should get you in the right direction. https://github.com/EsotericSoftware/spi ... pineboy.cs
You can add this as a component to your own game asset.

If you need the animations to blend you can select your data asset and click Add Mix

Image removed due to the lack of support for HTTPS. | Show Anyway

Shiu escribió

You can take a look at the example unity project.
In there is a file called Spineboy.cs which should get you in the right direction. https://github.com/EsotericSoftware/spi ... pineboy.cs
You can add this as a component to your own game asset.

If you need the animations to blend you can select your data asset and click Add Mix

Image removed due to the lack of support for HTTPS. | Show Anyway

Thanks, it is truly useful advice. :yes: :happy:

I've updated the example to also show how to use a lambda for an AnimaionState callback. For events it looks like:

skeletonAnimation.state.Event += (state, trackIndex, e) => {
   Debug.Log(trackIndex + " " + state.GetCurrent(trackIndex) + ": event " + e + ", " + e.Int);
};

Hey Nate,
I was looking for this too, But how do i actually access it so i can make the character transition? is their a way to access this information in the Animator window?

There are two parts.

1) You can play animations: set the current animation and/or add an animation to be played later.
2) When animations change they can be cross faded (aka mixed). Set the mixes as Shiu has shown, then when the animation changes, it is automatically cross faded.

You can do these things on multiple tracks, to apply multiple animations each from (eg shoot + walk/run/jump/swim/etc).

Spine currently doesn't use Unity's Animation window.

Thanks for answering so quick Nate, but im still at a loss. I have my animations set up exactly as Shiu as shown. But from where do i control the actual movements from?

Thanks

You scripts call SetAnimation or AddAnimation on the SkeletonAnimation component as needed. See the Spineboy.cs that Shiu linked above. You can open the spineboy example scene in the spine-unity runtime and play with Spineboy.cs there.

Thanks thats a real help. I got it to work on Spine boy and my own character as well.

Last question is their a tutorial on how to hook spine animations on to controls, keyboard, mouse, Mobile etc??

Not really, once you know how to set animations its just a matter of doing it as a response to input.

the spineboy.cs file in the sample package doesn't let me control the character just waits for two seconds, jumps then runs. Any chance of a tutorial of how to use spine animations within Unity? for coder beginners?

There is a lot to do on Spine, so honestly I don't think we'll have bandwidth for that any time soon. It's standard Unity stuff though, there should be lots of information on the web, Unity's site and forum, etc.

Hey Nate,
Im trucking my way through the Unity tutorials alright, But their is very little on implementation of spine in Unity, i have all my animations made and their imported and ready to go but i dont have access to them through the Animator. So i have to use code and spine specific references of which their is little on forums for the beginner, thats the information i'm after. Is their any way the runtime could let you connect back into the unity animator engine?

There might be a way, depends on how much Unity exposes. I haven't had a chance to look into it further, but I will when I can.

Thanks a million Nate. Back to the tutorials for me.

The example project has a collider in there to test for mousedown. I was playing around with Unity a bit the other day and ended up changing the code a bit. It's nothing fancy, but this just allows you to press a key on your keyboard to trigger an animation instead. It still doesn't move the character around but I thought I'd share anyways.

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

public class spineboy : MonoBehaviour {
   SkeletonAnimation skeletonAnimation;
   SkeletonData skeletonData;
   
public void Start () { // Get the SkeletonAnimation component for the GameObject this script is attached to. skeletonAnimation = GetComponent<SkeletonAnimation>(); skeletonAnimation.state.SetAnimation (0, "run", true); }
public void Event (Spine.AnimationState state, int trackIndex, Spine.Event e) { //Debug.Log(trackIndex + " " + state.GetCurrent(trackIndex) + ": event " + e + ", " + e.Int); } public void Update() { if (Input.GetKeyUp (KeyCode.Space)) { skeletonAnimation.state.SetAnimation (0, "jump", false); skeletonAnimation.state.AddAnimation (0, "run", true, 0); } } }

Shiu, note your IF in the update function doesn't have curly braces. SetAnimation will only be called when space is pressed, but AddAnimation will be called every update.

Nate escribió

Shiu, note your IF in the update function doesn't have curly braces. SetAnimation will only be called when space is pressed, but AddAnimation will be called every update.

Oops I was cleaning up the code a bit and must have removed that by accident. Fixed the original post.

15 días más tarde

Hello! I have a problem in Unity with Spine's meshes, when some animation transit between each other. Did you have some advice, or decision of this funny stuff?