- Изменено
Simple way to check for animation end?
I am new to C# and Unity and i'm having trouble finding out how to check if an animation has ended. In GMS2 there was a function that returns the full amount of frames that the animation has, and a function that checks the current frame of an animation playing, so if they were equal that would mean that the animation has ended.
I read up on a bunch of the documentation for Spine in C#, and i managed to change and mix between animations but i just can't figure out how to end them
You could use TrackEntry isComplete
. If you just want the animation to no longer be applied, you can set TrackEntry endTime
to Animation duration
.
Note animations use time in seconds, not frames, but you can compute the frame (eg, time * 30
if you are using 30 frames per second).
Nate написалYou could use TrackEntry
isComplete
. If you just want the animation to no longer be applied, you can set TrackEntryendTime
to Animationduration
.Note animations use time in seconds, not frames, but you can compute the frame (eg,
time * 30
if you are using 30 frames per second).
Hey, i managed to end the animation by following the example from: Coding for Spine Events and AnimationState callbacks
I put an "anim_end" event at the end of every animation in spine, and then i check when it happens through code. Do you think i should use the TrackEntry isComplete method instead?
Putting an event at the end of every animation is a bit tedious. You can do anything that works, but checking isComplete
or the animation time is easiest.
Instead of adding an event at the end time of each animation, is there a problem with using the Complete
event?
Pharan написалInstead of adding an event at the end time of each animation, is there a problem with using the
Complete
event?
Well the only problem is that i'm not too experienced as a programmer so i'm having a tough time understanding how to use TrackEntry .
From the event example i understood i have to use the subscribe method
public SkeletonAnimation spine;
[SpineEvent] public string footstep = "Footstep";
bool footstepParticle = false;
void Start () {
// Spine subscribe to Event
spine.AnimationState.Event += HandleEvent;
spine.AnimationState.Start += delegate (TrackEntry trackEntry) {
};
spine.AnimationState.End += delegate {
};
}
void HandleEvent(TrackEntry trackEntry, Spine.Event e)
{
if (e.Data.Name == footstep)
{
footstepParticle = true;
}
}
This i mostly understand how to use for different events, but i haven't found any examples on how to end an animation using TrackEntry isComplete.