• Runtimes
  • [Unity3D, TK2D]Guide - Importing a Spine Animation into TK2D

Related Discussions
...
  • تم التحرير

Hi
I have followed this guide and its very cool.
my question is can i still use all the spine runtime features in the tk2d like add and mix animation etc.
from the example provided i can only swap animations and toggle the loop.
Ive tried adding and mixing from the docs but have had no luck so far.

thanks

Yes, you can access the skeleton field and use the spine-csharp API.

public class Knight : MonoBehaviour {
	private tk2dSpineAnimation skeleton;
	
void Start() {
	skeleton = GetComponent<tk2dSpineAnimation>();
}

void LateUpdate() {
	if (skeleton.loop) return;
	
	if (skeleton.state.Animation != null && skeleton.state.Time >= skeleton.state.Animation.Duration - 0.25) {
		skeleton.animationName = "walk";
		skeleton.loop = true;
	}
}

void OnMouseDown() {
	skeleton.animationName = "Swipe";
	skeleton.loop = false;
}
}

Hi thanks for your reply.

How do i get the skeleton field ?
I've been using the above code how could i combine the walk animation with the swipe ?
the swipe animation has no keys in the legs .
I'm aware of the principle and how it should work I've been through the run time docs but cant get anything I've tried to work so far.
does anyone have an example.

thanks

Hello,

In your example you are accessing the tk2dSpineAnimation.

To get to the csharp api skeleton you can go via the tk2dSpineSkeleton something like...

private List<Bone> bones;

skeleton = GetComponent<tk2dSpineSkeleton>();

if(skeleton == null) throw new ArgumentNullException("skeleton");	
        
bones = skeleton.skeleton.Bones; if(bones == null) throw new ArgumentNullException("bones"); foreach(Bone bone in bones) { Debug.Log("Bone " + bones.IndexOf(bone) + " " + bone.ToString()); }

Cheers

evs

That was terrific! Great vid, and really really helpful. Would love to see you make additional vids on the subject.

best,
Brendan G.

Thanks evs i Will try out your method Later today.
The video was really helpfull for getting animations into unity.
I also would love to see additional videos like this.
thanks guidez

Can we get this moved into the "Runtimes" Forum? Thanks!

شهر واحد لاحقا

Is there a tutorial on importing Spine Animation into Unity without TK2D?

I can make one, just need a bit of time.