• RuntimesUnity
  • [Unity] Animation on a higher track layer not fully overriding the layer below

so I'm trying to crack my head on a problem I had in a while. I have a set up that allows my character to move on layer 0, and then attack animations on layer 1. I've added in spine a keyframe to anything I wanted to override, however some bones and texture slots continue to use the animation in layer 0.

the main culprits are the shoulder in front, and the torso slot continuing to change. even though both are overriden by the attack animation

as far as what's happening in the code, it's (_Body and _Attack are both the track entries for the respective tracks):
for the idle/walk/run loop:

`public void GroundedMovementAnimationUpdate(float speed)
{
float transition = 0.2f;
if (_Body.Animation == null || _Body.Animation.Name == "Falling") transition = 1;

if (speed < _WalkSpeedTreshold)
{
    if (_Body.Animation == null || _Body.Animation.Name != "Idle") _Body = _state.SetAnimation(0,"Idle",true);
    _Body.MixDuration = transition;
    _Body.TimeScale = 1;
}
if (speed < _RunSpeedTreshold && speed > _WalkSpeedTreshold)
{
    if (_Body.Animation == null || _Body.Animation.Name != "Walk") _Body = _state.SetAnimation(0, "Walk", true);
    _Body.MixDuration = transition;
    _Body.TimeScale = speed*_movespeedmultiplier;
}
if (speed > _RunSpeedTreshold)
{
    if (_Body.Animation == null || _Body.Animation.Name != "Run") _Body = _state.SetAnimation(0, "Run", true);
    _Body.MixDuration = transition;
    _Body.TimeScale = speed * _movespeedmultiplier;
}

}`

for the strike animations:

`public void Attack(string AttackName)
{
if (_Attack.Animation == null || _Attack.Animation.Name != AttackName)
{
_Attack = _state.SetAnimation(1, AttackName, false);
_Attack.MixDuration = 0f;
_Attack.MixBlend = MixBlend.Replace;


    _Attack = _state.AddEmptyAnimation(1, 0.2f, -0.2f);
}

}`

help.

Related Discussions
...

It seems like the issue you're experiencing is related to the way animations are being blended across different tracks. In Spine, animations on higher tracks should override those on lower tracks, but this only happens if the higher track animations have keys for the properties you want to override. If some bones or slots are not being overridden, it might be because they are not keyed in the attack animation. Ensure that the attack animation has keyframes for all the bones and slots you want to override. Additionally, when using SetAnimation and AddEmptyAnimation, make sure that the MixBlend is set correctly to MixBlend.Replace to ensure that the higher track fully overrides the lower track. You might also want to check if the MixDuration is set appropriately to allow for a smooth transition.

    Spinebot

    the mixblend is already set to MixBlend.Replace
    the problem i'm experiencing is that the higher track is still not properly overriding the underlying animation

    • इस पर Harald ने जवाब दिया।

      @AVioletSummer Did you perhaps export with Animation Clean up enabled? Note that this will remove keys identical to the setup pose unless the animation has Layered enabled (in the Tree view select your animation and check Layered).

      AVioletSummer the mixblend is already set to MixBlend.Replace

      Calling entry.mixBlend = MixBlend.Replace; is not necessary as this is already the default.

        @AVioletSummer As a side note: you can format multi-line code blocks in this forum by wrapping them in triple-backticks "```", not single backticks "`".

        Harald THX! that was indeed the problem

        also, good to know about the code blocks. the button for codeblocks in the UI only put down 2 so that confused me.

        • Harald ने इसे लाइक किया।

        @AVioletSummer Glad it helped, thanks for letting us know.