Majicpanda

It seems that you have to click on the game object in order to initialize the bounding box that you place a BoundingBoxFollower and BoneFollower on even with the below code. Is there any way to to make it so it doesn't require using the editor?

The problem is I have 100 monsters or so and I dynamically instantiate the spine animation under a graphics child of "Monster" instead of making a prefab for every single one and a child with the bounding box.
//bounding box collider owner
GameObject go = new GameObject("SpineHitBox");
go.transform.SetParent(animGo.transform, false);
go.AddComponent<SpineAttackBox>();
BoundingBoxFollower bbf = go.AddComponent<BoundingBoxFollower>();
bbf.slotName = "WeaponHitBox";
BoneFollower bf = go.AddComponent<BoneFollower>();
bf.boneName = "weapon";
go.layer = LayerMask.NameToLayer("Skill");


-- 19 Sep 2015, 10:43 --

Figured it out
public class SpineAttackBox : MonoBehaviour {

private BoundingBoxFollower boundingFollower;
private BoneFollower boneFollower;

void Awake()
{
boundingFollower = gameObject.AddComponent<BoundingBoxFollower>();
boundingFollower.skeletonRenderer = SkeletonUtility.GetInParent<SkeletonRenderer>(transform);
boundingFollower.slotName = "WeaponHitBox";
boneFollower = gameObject.AddComponent<BoneFollower>();
boneFollower.skeletonRenderer = SkeletonUtility.GetInParent<SkeletonRenderer>(transform);
boneFollower.boneName = "weapon";

boneFollower.DoUpdate();
boneFollower.skeletonRenderer.Reset();
}
}
Majicpanda
  • Posts: 197


Return to Unity