- Edited
BoundingBoxFollower - errors when object is reactivated
So I have an enemy that can do melee attack, for which I'm using Bounding Box.
I followed this tutorial:
My setup is basically the same. In the video, "WeaponHitbox" child object is used - I have it like this:
During runtime, when I deactivate the Enemy object (i.e. the parent of Rifle object), and reactivate it again, the Attachment Name "rifle_hitbox" disappears, like this:
When I then try to play the melee attack animation, I get an error just when the polygon collider should appear:
KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary`2[Spine.BoundingBoxAttachment,UnityEngine.PolygonCollider2D].get_Item (Spine.BoundingBoxAttachment key) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
BoundingBoxFollower.SetCurrent (Spine.BoundingBoxAttachment attachment) (at Assets/Extensions/Spine/spine-unity/spine-unity/BoundingBoxFollower.cs:181)
BoundingBoxFollower.LateUpdate () (at Assets/Extensions/Spine/spine-unity/spine-unity/BoundingBoxFollower.cs:172)
Which indeed seems to refer to that missing "rifle_hitbox" Attachment Name.
Is there anything I can do to alleviate this issue? Can I somehow reset the BoundingBoxFollower manually after I've reactivated the Enemy parent object?
I'm using Unity 5.2.0f Personal.
Thank you very much!
Thought I fixed this...
void OnEnable () {
ClearColliders();
if (skeletonRenderer == null)
skeletonRenderer = GetComponentInParent<SkeletonRenderer>();
if (skeletonRenderer != null) {
skeletonRenderer.OnReset -= HandleReset;
skeletonRenderer.OnReset += HandleReset;
if (hasReset) {
HandleReset(skeletonRenderer);
}
}
}
Not the most efficient solution ever, but here.
Mitch wroteThought I fixed this...
Darn, you actually did. I checked the latest runtimes and found I had an old copy really sorry for taking your time but thanks for the fix! It works