rautatrukki

In unity how I can activate function when Spine animation ends?
rautatrukki
  • Mesajlar: 5

Nate

Once event timeline is done you can use that. Until then you can use the AnimationState time or AnimationState isCompleted.
Kullanıcı avatarı
Nate

Nate
  • Mesajlar: 12213

rautatrukki

Is there a option to ask what animation is now playing?

example:

if(animationplayingname == "attack" && skeletonAnimation.state.Time <= 0) {
dosomething();
}

Or is there a better way to do this?

Thanks! :)

Edit: I found it! skeletonAnimation.state.Animation.Name

Thanks for help Nate and for fast answers! :)
rautatrukki
  • Mesajlar: 5

Nate

Bingo! :clap:
Kullanıcı avatarı
Nate

Nate
  • Mesajlar: 12213

Pharan

As a sidebar, Nate:

For checking the current animation of an AnimationState, particularly in C#/Java;
What do you think of:
(a) using a string compare (by checking if AnimationState.Animation.Name == "animationname")

vs.

(b) using a reference compare (by checking if AnimationState.Animation == a cached Spine.Animation reference, probably preloaded at initialization with SkeletonData.FindAnimation("animationname") )
?

Really not a point of concern? Any design considerations?
Kullanıcı avatarı
Pharan
  • Mesajlar: 5366

Nate

A single string comparison is (generally) fine. Many string comparisons isn't so great. The reference comparison is obviously more efficient, but unless the difference actually affects the application user (and it most likely doesn't) then fretting over the difference is a misuse of your time. :)
Kullanıcı avatarı
Nate

Nate
  • Mesajlar: 12213


Dön Runtimes