Exemplo n.º 1
0
        public static void IgnoreEveryBoneCollisions(Rigidbody rb, SlaveHandModel hand, bool ignore, bool includeRbGroup)
        {
            SlaveBoneModel  bone;
            List <Collider> rbColliders = new List <Collider>(rb.GetComponentsInChildren <Collider>());

            RigidbodyGroup rbGroup = rb.GetComponent <RigidbodyGroup>();

            if (rbGroup && includeRbGroup)
            {
                for (int i = 0; i < rbGroup.rigidbodies.Length; i++)
                {
                    rbColliders.AddRange(GetColliders(rbGroup.rigidbodies[i]));
                }
            }

            for (int i = 0; i < rbColliders.Count; i++)
            {
                for (int j = 0; j < hand.bones.Length; j++)
                {
                    if (hand.bones[j] is SlaveBoneModel)
                    {
                        bone = hand.bones[j] as SlaveBoneModel;

                        if (bone.colliderRef != null)
                        {
                            Physics.IgnoreCollision(rbColliders[i], bone.colliderRef, ignore);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static void IgnoreBoneCollisions(Rigidbody rb, SlaveBoneModel bone, bool ignore, bool includeRbGroup)
        {
            if (!bone.colliderRef)
            {
                return;
            }

            List <Collider> rbColliders = new List <Collider>(rb.GetComponentsInChildren <Collider>());

            RigidbodyGroup rbGroup = rb.GetComponent <RigidbodyGroup>();

            if (rbGroup && includeRbGroup)
            {
                for (int i = 0; i < rbGroup.rigidbodies.Length; i++)
                {
                    rbColliders.AddRange(GetColliders(rbGroup.rigidbodies[i]));
                }
            }

            for (int i = 0; i < rbColliders.Count; i++)
            {
                Physics.IgnoreCollision(rbColliders[i], bone.colliderRef, ignore);
            }
        }