IndieDoroid

Hi guys,

I'm trying to wrap my head around Track Entry and can't get it to work consistently. I want the game object to deactivate after completing it's animation. 50% of the time it works the other times the object instantly deactivates BEFORE playing it's animation.
http://esotericsoftware.com/spine-unity-events#AnimationState-vs-TrackEntry-events

using Spine;
using Spine.Unity;

void Update()
{
_skeletonAnimation.AnimationState.Event += HandleEvent; //Its a RED error in VS

_skeletonAnimation.AnimationState.Complete += delegate (TrackEntry trackEntry)
{
gameObject.SetActive(false); //Game Object instantly gets deactivated before the animation can complete
};
}
I tried an event instead, but SkeletonAnimation game objects don't recognize animator controllers. Any help is appreciated.
Kullanıcı avatarı
IndieDoroid
  • Mesajlar: 257

Nate

A couple things:
  • Your code listing is incomplete. Do you define HandleEvent?
  • Setting a listener for AnimationState will fire for ALL animations. You probably either want to check which animation the track entry is for, or set the listener on the TrackEntry returned when you call setAnimation or addAnimation.
Kullanıcı avatarı
Nate

Nate
  • Mesajlar: 12144


Dön Runtimes