rautatrukki

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

Nate

Once event timeline is done you can use that. Until then you can use the AnimationState time or AnimationState isCompleted.
アバター
Nate

Nate
  • 記事: 9730

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
  • 記事: 5

Nate

Bingo! :clap:
アバター
Nate

Nate
  • 記事: 9730

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?
アバター
Pharan
  • 記事: 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. :)
アバター
Nate

Nate
  • 記事: 9730


Return to Runtimes