RagdollBone GetCollidingBone(Collision collision)
        {
            Rigidbody   rigidbody = collision.GetContact(0).thisCollider.attachedRigidbody;
            RagdollBone bone      = bones[rigidbody];

            return(bone);
        }
Ejemplo n.º 2
0
        CollisionEventDispatcher SetUpCollisionEventDispatcher(RagdollBone bone)
        {
            CollisionEventDispatcher dispatcher = bone.Rigidbody.gameObject.AddComponent <CollisionEventDispatcher>();

            dispatcher.OnCollisionEntered += DispatchOnCollisionEnter;
            dispatcher.OnCollisionStayed  += DispatchOnCollisionStay;
            dispatcher.OnCollisionExited  += DispatchOnCollisionExit;

            return(dispatcher);
        }
Ejemplo n.º 3
0
        bool TryCreateRagdollBones()
        {
            if (!BindingsAreValid)
            {
                if (Application.isPlaying)
                {
                    UnityEngine.Debug.LogError("Ragdoll Definition Bindings aren't correctly set up.", this);
                }
                return(false);
            }

            bones = new Dictionary <BoneName, RagdollBone>();

            //Create the bones
            foreach (BoneName boneName in bindings.Keys)
            {
                ConfigurableJoint joint = bindings[boneName];

                RagdollBone bone = new RagdollBone(boneName, joint.transform, joint.GetComponent <Rigidbody>(), joint, _definition.IsRoot(boneName));
                bones.Add(boneName, bone);
            }

            return(true);
        }
Ejemplo n.º 4
0
        public bool TryGetBone(BoneName boneName, out RagdollBone bone)
        {
            ThrowExceptionIfNotInitialized();

            return(bones.TryGetValue(boneName, out bone));
        }