unity spine boundingbox 碰撞检测

(更多功能见后篇http://blog.csdn.net/xiyouice/article/details/79571362)

unity spine boundingbox 碰撞检测_第1张图片
1、在spine的对象下建立物理骨骼并选择”follow”

unity spine boundingbox 碰撞检测_第2张图片
2、如果该spine动画已经由美术添加了BoundingBoxes,那在相应的骨骼节点就可以自动生成多边形碰撞体,点击上图(weapon2)
unity spine boundingbox 碰撞检测_第3张图片
3、由于项目要求可以替换武器,也就是更换了spine的skin之后,碰撞体也要同时刷新

 功能代码段
    private void freshWeapon(){
        Destroy(weaponBone.transform.FindChild("[BoundingBox]weapon2").gameObject);
        // 因为这里的AddBoundingBox不会自动刷新已经存在的属性值,所以要先把之前的destroy掉
        weaponBone.AddBoundingBox(skeleton.skin.Name,"weapon2","weaponBJ");
        weaponBone.transform.FindChild("[BoundingBox]weapon2").gameObject.AddComponent();
        // weaponBone.DoUpdate(SkeletonUtilityBone.UpdatePhase.Complete); 这个刷新函数不调用也没区别
    }

   /// 
   /// 更换套装
   /// 
   /// 
   /// 套装的名字
   public void DressUp(Skeleton skeleton,string skinName)
   {
      skeleton.SetSkin(skinName);
   }

    void Update () {
        if (Input.GetKeyDown(KeyCode.A)){
            SpineTool.Instance.DressUp(skeleton,"weapon");
            freshWeapon();
        }
        else if (Input.GetKeyDown(KeyCode.B)){
            SpineTool.Instance.DressUp(skeleton,"weapon2");
            freshWeapon();

        }
        else if (Input.GetKeyDown(KeyCode.C)){
            SpineTool.Instance.DressUp(skeleton,"weapon3");
            freshWeapon();

        }

你可能感兴趣的:(u3d,spine,unity,spine-换装,spine)