The code below runs in each update, does it waste performance, and should I check the status of the track and only change it if it's not what it's supposed to be?
The variable crouchTrack below is track 1, and there's another animation like idle/walking on track 0.
if (isCrouching || isCrawling) {
skeletonAnimation.AnimationState.SetAnimation(crouchTrack, "crouchDown", true);
} else {
skeletonAnimation.AnimationState.SetEmptyAnimation(crouchTrack, 0);
}
Here's my try with a check, however this checks on track 0 (or all tracks?) so it doesn't work and the crouch gets stuck. So how would I check what is playing on track 1?
if (skeletonAnimation.AnimationName != "crouchDown" && (isCrouching || isCrawling)) {
skeletonAnimation.AnimationState.SetAnimation(crouchTrack, "crouchDown", true);
} else if (skeletonAnimation.AnimationName == "crouchDown" && !(isCrouching || isCrawling)) {
skeletonAnimation.AnimationState.SetEmptyAnimation(crouchTrack, 0);
}
Thanks 🙂