void Update() { if (characterMovement.freeFalling) { ragdollController.GoRagdoll("free fall"); } // if we're falling, dont let us go "up" // ragdoll was falling up stairs... characterMovement.preventUpwardsGroundedMotion = ragdollController.state == RagdollControllerState.Falling; // dont accept any movement changes from player input, or ai input characterMovement.disableExternalMovement = ragdollController.state != RagdollControllerState.Animated || ragdollController.isGettingUp; /* * skip moving the main transform if we're completely ragdolled, or waiting to reorient * the main transform via the ragdoll controller */ characterMovement.disableAllMovement = ragdollController.state == RagdollControllerState.Ragdolled || ragdollController.state == RagdollControllerState.TeleportMasterToRagdoll; /* * when animated or blending to animation * use character controller movement * * it has less step offset jitter than the normal transform movement * especially when getting up * * else when falling: * * use normal transform stuff (dont want the character controller collisions messing stuff up) * for falling /calculating fall ( we need all exterion collisions to reach ragdol bones) * and teh characer chontroller acts as a 'protective shell' when it's enabled */ characterMovement.usePhysicsForMove = ragdollController.state == RagdollControllerState.Animated || ragdollController.state == RagdollControllerState.BlendToAnimated; //cehck if we started getting up if (ragdollController.state == RagdollControllerState.BlendToAnimated) { //set zero speed if (characterMovement.currentSpeed != 0) { characterMovement.SetMovementSpeed(0); } } int currentSpeed = (int)characterMovement.currentSpeed; if (currentSpeed < 0 || currentSpeed >= fallDecaySpeeds.Length) { Debug.LogError("current speed: " + currentSpeed + " :: out of range for fall decays"); } else { //set the ragdolls fall speed based on our speed ragdollController.SetFallSpeed(fallDecaySpeeds[(int)characterMovement.currentSpeed]); } }
void Update() { //cehck if we started getting up if (ragdollController.state == RagdollControllerState.BlendToAnimated) { //set zero speed if (currentSpeed != 0) { SetMovementSpeed(0); } } //set the ragdolls fall speed based on our speed ragdollController.SetFallSpeed(currentSpeed == 0 ? idleFallSpeed : (currentSpeed == 1 ? walkFallSpeed : runFallSpeed)); ApplyMovement(UpdateMode.Update); }
void UpdateLoop() { if (ragdollController.state == RagdollControllerState.Animated) { if (characterMovement.freeFall) { ragdollController.GoRagdoll(" free fall "); } } // CheckCameraTarget(); // characterMovement.preventUpwardsMotion = ragdollController.state == RagdollControllerState.Falling; /* * skip moving the character transform if we're completely ragdolled, * or waiting to reorient the main transform through the ragdoll controller */ characterMovement.enableMovement = ragdollController.state != RagdollControllerState.Ragdolled && ragdollController.state != RagdollControllerState.TeleportMasterToRagdoll; if (!characterMovement.enableMovement) { characterMovement.SetMoveDelta(Vector3.zero); characterMovement.SetRotationDelta(Vector3.zero); } /* * when animated or blending to animation * use character controller movement * * it has less step offset jitter than the normal transform movement * especially when getting up */ // on start blend to anim: // usePhysicsController = true // if (ragdollController.state == RagdollControllerState.Animated || ragdollController.state == RagdollControllerState.BlendToAnimated) { // characterMovement.usePhysicsController = true; // } // else { /* * when falling * * use normal transform stuff (dont want the character controller collisions messing stuff up) * for falling /calculating fall ( we need all exterion collisions to reach ragdol bones) * and teh characer chontroller acts as a 'protective shell' when it's enabled */ // on start fall (on ragdoll) // usePhysicsController = false // characterMovement.usePhysicsController = false; // } //cehck if we started getting up // if (ragdollController.state == RagdollControllerState.BlendToAnimated) { // //set zero speed // if (movementController.speed != 0) { // movementController.speed = 0; // } // } //set the ragdolls fall speed based on our speed ragdollController.SetFallSpeed(movementController.speed == 0 ? idleFallSpeed : (movementController.speed == 1 ? walkFallSpeed : runFallSpeed)); }