NSantos

I was having an issue with ground constraint in which it was not working properly.

Basically I had a character with two ground constraints on its feet.



The issue I was having is that one foot worked fine...



... while the other didn't. I would adjust it but afterwards it wouldn't come back down.



I did a lot of digging on Spine Code and I found out that for the bones to reset properly the animation update must include a TranslateTimeline for these bones - in other words, there must be some translate keys set in Spine for the animations.

We solved it, by adding a slight/minimal change to the foot position (0.00001 or something in the animation that caused the issue), and now have to make sure that for all animations the feet move (even if it's not perceptible).

Is this intended? Or am I missing something here?
NSantos
  • Posts: 7

Harald

NSantos wrote:We solved it, by adding a slight/minimal change to the foot position (0.00001 or something in the animation that caused the issue), and now have to make sure that for all animations the feet move (even if it's not perceptible).
You don't need to move the bone, you just need to key it (in the first frame). Just be sure to have Animation cleanup disabled upon exporting your skeleton, otherwise your keys identical to the setup pose would be removed again.
NSantos wrote:Is this intended? Or am I missing something here?
It's more of an implicit logical side-effect than intended behaviour. The SkeletonUtilityGroundConstraint limits the vertical location to ground height, by moving it up when below that height. Now when nothing (no animation which keys the bone location and no other user-code) updates the bone location, SkeletonUtilityGroundConstraint does also nothing to move the location down. There is no simple moving-down logic present because the component can't easily distinguish whether the animation just was not moving the bone this frame (and wants to keep it at this height deliberately), or if no animation was affecting the bone location at all.

This could be worked around by setting the bone location to the setup pose each frame, so when no animation is applied afterwards, it gets the setup pose bone location every frame. You could create your own subclass of SkeletonUtilityGroundConstraint with just this Update method added:
void Update () {
bone.bone.X = bone.bone.Data.X;
bone.bone.Y = bone.bone.Data.Y;
}
Alternatively you coudl also register a similar method to SkeletonAnimation.UpdateLocal to be sure the update order does not depend on the component names.
User avatar
Harald

Harri
  • Posts: 4459

NSantos

Alright thanks for the clarifications :)
NSantos
  • Posts: 7

Harald

You're welcome. :)
User avatar
Harald

Harri
  • Posts: 4459


Return to Unity