Thanks for this reply Pharan.
I changed to SpineAnimation and have the same problem unfortunately.. so looks to not be Unity's fault after all.
After looking a bit further into this, would you see a potential problem if you had Attack 1 and Attack 2.. both 30 frames for simplicity sake. Use SetAnimation(0, anim1, false) and at frame 20 enable a mainhand hit box, 28 disable.. at 85% call SetAnimation(0, anim2, false). I assumed this would mix the 2 (and it does) but does anim 2 possibly cause the hitbox code to be completely ignored?
Here's something really screwy to add... it doesn't happen if I have the enemy clicked in the unity hierarchy.... :bang:
I tested it 50x.. it is not coincedence, it literally happens every time when not selected and never when I do have the enemy selected. I was trying to capture a zoomed in video of the colliders enabling and disabling for you but apparently that won't be happening.
My exact case scenario is I have a 75 frame animation and have an attack with colliders enabling at frame 62 and disable at 66. I moved the disable to 64 and it no longer has an issue. I definitely think something is up at the end of mixes. If the attack leads to an idle etc the hitbox simply remains enabled allowing the enemy to endlessly "attack" by running into you etc.
In response to the "disable all colliders" part I think we could simply disable all bounding boxes any time any attack animation ends but yea that might get ugly =/ .. I'll hold it in our back pocket if nothing stands out as an easily fixable problem in the runtime.
Edit: I tried getting the polygon colliders and disabling them all at the end of my attack animations and 10x more stuff went haywire including things not enabling correctly lol..
using System.Collections.Generic;
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
using Spine.Unity;
namespace NodeCanvas.Tasks.Actions
{
[Category("Picklefeet")]
public class PlayAnimationSpine : ActionTask<Transform>
{
private SkeletonAnimation skeletonAnimation;
private Spine.AnimationState spineAnimationState;
private Spine.TrackEntry trackEntry;
private Blackboard bb;
private List<PolygonCollider2D> boundingColliders = new List<PolygonCollider2D>();
[RequiredField]
public string animationClip;
[SliderField(0, 4)]
public int layer = 0;
public bool loop = false;
public bool isAttack;
protected override string info
{
get { return "Anim " + animationClip.ToString(); }
}
protected override string OnInit()
{
if (skeletonAnimation == null)
{
skeletonAnimation = agent.GetComponentInChildren<SkeletonAnimation>();
spineAnimationState = skeletonAnimation.state;
bb = agent.GetComponent<Entity>().bbAnimation;
BoundingBoxFollower[] followers = agent.GetComponentsInChildren<BoundingBoxFollower>();
foreach(BoundingBoxFollower bbf in followers)
{
foreach(KeyValuePair<Spine.BoundingBoxAttachment, PolygonCollider2D> entry in bbf.colliderTable)
{
boundingColliders.Add(entry.Value);
}
}
}
return null;
}
protected override void OnExecute()
{
trackEntry = spineAnimationState.SetAnimation(layer, animationClip, loop);
if (isAttack)
{
bb["meleeAttack"] = false;
bb["attackChain"] = false;
}
bb["animNormalizedTime"] = 0f;
bb["attackNormalizedTime"] = 0f;
}
protected override void OnUpdate()
{
float normalizedTime = trackEntry.time / trackEntry.endTime;
if(isAttack)
{
bb["attackNormalizedTime"] = normalizedTime;
if(normalizedTime < .5f)
{
bb["inputLock"] = true;
}
else
{
bb["inputLock"] = false;
}
}
bb["animNormalizedTime"] = normalizedTime;
//if this animation doesn't loop, immediately end and transition out when completed
if(!loop && normalizedTime >= .85f)
{
//if this is an attack and we go past the point of no return for a chain attack, ensure everything is reset
if (isAttack)
{
bb["meleeAttack"] = false;
bb["attackChain"] = false;
for(int i=0; i< boundingColliders.Count; i++)
{
boundingColliders[i].enabled = false;
}
}
EndAction(true);
}
}
}
}
Edit... sorry Pharan, lmao... I changed the Default Mix to .01 and it still behaves incorrectly which makes sense.. this time it's starting a state transition at 85% into the animation and then instantly setting the new animation which would definitely skip the frames. I don't understand how the mixing works that would result in ignoring the end of attack 1's frames. This seems like it could cause problems with mesh deformation and all the other systems, but maybe they aren't so obvious as non looping attacks.