• Unity
  • Swapping Images and resetting

Related Discussions
...

How would you set up and code a system where you changed images under a slot but then needed to change them back and don't always know what the TO animation will be?

Key framing every single known slot you swap in game at the beginning of every animation seems quite cumbersome.

A workflow I'd want is at the start of any animation it used a base of some sort unless the slot specifically has a key frame to set an image. Any suggestions can use the latest runtimes as I'm willing to upgrade to the new AnimationState if this fixes things.

The new AnimationState does act as you described.

And we agree that keying every single slot, (or worse, every single transform property for every bone) is a terrible idea.
The slightly better alternative would have been calling skeleton.SetSlotsToSetupPose at the start of every animation.

Thanks Pharan I'll take the time to update our project and exports as soon as everything is stable.

How does the new animationState change the behavior of something like this:
Anim 1 has an event at frame 30, it's 35 frames long
You use SetAnimation to play Anim 2 at frame 28 expecting a mix between 1 and 2 which does visually happen but the event is lost.

AnimationState 3.4 ignores user events from outgoing animations (TrackEntry) during a transition/mix.
I added a bit of code a while back to spine-csharp if you need them to fire all the time: spine-runtimes/AnimationState.cs at master

In the new AnimationState 3.5, TrackEntries have an TrackEntry.EventThreshold property.
This means you can customize per SetAnimation if you want a TrackEntry to fire its events even if it's outgoing, if the mix/transition/crossfade is by a certain amount.

If it's 0, the events never fire when outgoing.
If it's 1, all events fire even if the animation is fading out.
If it's 0.5, the events stop firing halfway through the transition.

There are similar properties named AttachmentThreshold and DrawOrderThreshold that act the same way for slot attachment and draw order keys.

Nice that's an interesting fix to apply.

Curious if I'm doing things wrong now though.. this is really only affecting my chain attacks.

If the player gets hit during an attack then I of course do not want to play the attack hit box, so the event threshold definitely should not be the fix here.

Attack 1 begins, frame 30 of 35 is a hitbox event i dispatch.
Player queues Attack 2 so the controller sees this and 85% into the animation (the part im curious is wrong) calls SetAnimation for Attack2. I tried waiting for 95% into animation but it snaps to Attack 2 instead of mixes even though my default mix is .2f

This requires me to put all events < 85% into any animation or they will never fire no matter what... not sure why this isn't a problem for anyone else. Do people wait for an animation to play through 100% before transitioning to another attack? I don't know how without it snapping to the new anim if so.