Exemplo n.º 1
0
        private void Update()
        {
            if (currentActivationTime != -1 && currentActivationTime < activationTime)
            {
                currentActivationTime = MyMath.min(activationTime, currentActivationTime + Time.deltaTime);

                //to keep the leg in "reset" position while making raise from ragdoll
                step.step.reset(stepper.transform.position, stepper.transform.rotation);
                step.step.undockCurTime = 0;
                bones.setTarget(step.step.posAbs, step.step.footOrientation);

                if (currentActivationTime == activationTime)
                {
                    mixer.enabled = false;
                    switcher.canRiseFromRagdoll = false;
                    stepper.needsUpdate         = true;//finally acquire new layout
                }
                else
                {
                    mixer.progress = currentActivationTime / activationTime;
                }
            }

            if (isRagdollOld != isRagdoll)
            {
                isRagdollOld = isRagdoll;
                if (isRagdoll)
                {
                    bodyJoint.connectedBody = stepper.transform.GetComponent <Rigidbody>();
                    mixer.enabled           = false;
                    switcher.startRagdoll();
                    switcher.canRiseFromRagdoll = false;
                    step.enabled        = false;
                    bones.enabled       = false;
                    stepper.needsUpdate = true;
                }
                else
                {
                    bodyJoint.connectedBody = null;
                    switcher.stopRagdoll();
                    switcher.canRiseFromRagdoll = true;

                    currentActivationTime = 0;
                    mixer.progress        = 0;

                    bones.enabled = true;
                    //stepper.needsUpdate = true;//to activate new layout immediately, but then invisible leg will step while rasing from ragdoll
                    step.enabled = true;

                    mixer.enabled = true;
                }
            }
        }
Exemplo n.º 2
0
        public void die()
        {
            Rigidbody stepperRb = stepper.GetComponent <Rigidbody>();
            Rigidbody ragdollRb = stepper.GetComponent <MoveenSkelWithBones>().bones[0].attachedGeometry.GetComponent <Rigidbody>();

            ragdollRb.velocity        = stepperRb.velocity * 1.5f;
            ragdollRb.angularVelocity = stepperRb.angularVelocity * 1.5f;

            ragdoller.enabled = true;
            ragdoller.startRagdoll();
            turnOffStepper();

            animator.enabled = false;
            animator.SetBool("Dead", true);
            animationToRagdoll.enabled = false;
            allToStepper.enabled       = false;
        }
Exemplo n.º 3
0
        private void Update()
        {
            if (isRagdollOld != isRagdoll)
            {
                isRagdollOld = isRagdoll;
                if (isRagdoll)
                {
                    switcher.startRagdoll();
                    transform.SetParent(null);
                    stepper.needsUpdate = true;
                    Destroy(bodyJoint);
                    bones.enabled = false;

                    Vector3 force = stepper.transform.position.sub(bodyJoint.transform.position).normalized(repulsion);
                    stepper.bodyRigid.AddForceAtPosition(force, bodyJoint.transform.position, ForceMode.Impulse);
                    bodyJoint.transform.GetComponent <Rigidbody>().AddForceAtPosition(-force, bodyJoint.transform.position, ForceMode.Impulse);
                }
            }
        }