public override void AfterCharacterUpdate(float deltaTime) { // Handle jump-related values { // Handle jumping pre-ground grace period if (machine._jumpRequested && machine._timeSinceJumpRequested > machine.JumpPreGroundingGraceTime) { machine._jumpRequested = false; } if (machine.AllowJumpingWhenSliding ? machine.Motor.GroundingStatus.FoundAnyGround : machine.Motor.GroundingStatus.IsStableOnGround) { // If we're on a ground surface, reset jumping values if (!machine._jumpedThisFrame) { machine._jumpConsumed = false; } machine._timeSinceLastAbleToJump = 0f; } else { // Keep track of time since we were last able to jump (for grace period) machine._timeSinceLastAbleToJump += deltaTime; } } if (machine.Motor.GroundingStatus.IsStableOnGround) { machine.StateChange(KeyValue, Idle); } }
public override void AfterCharacterUpdate(float deltaTime) { // Handle jump-related values { // Handle jumping pre-ground grace period if (machine._jumpRequested && machine._timeSinceJumpRequested > machine.JumpPreGroundingGraceTime) { machine._jumpRequested = false; } if (machine.AllowJumpingWhenSliding ? machine.Motor.GroundingStatus.FoundAnyGround : machine.Motor.GroundingStatus.IsStableOnGround) { // If we're on a ground surface, reset jumping values if (!machine._jumpedThisFrame) { machine._jumpConsumed = false; } machine._timeSinceLastAbleToJump = 0f; } else { // Keep track of time since we were last able to jump (for grace period) machine._timeSinceLastAbleToJump += deltaTime; } } // Handle uncrouching if (machine._isCrouching && !machine._shouldBeCrouching) { // Do an overlap test with the character's standing height to see if there are any obstructions machine.Motor.SetCapsuleDimensions(0.5f, 2f, 1f); if (machine.Motor.CharacterOverlap( machine.Motor.TransientPosition, machine.Motor.TransientRotation, machine._probedColliders, machine.Motor.CollidableLayers, QueryTriggerInteraction.Ignore) > 0) { // If obstructions, just stick to crouching dimensions machine.Motor.SetCapsuleDimensions(0.5f, 1f, 0.5f); } else { // If no obstructions, uncrouch machine.MeshRoot.localScale = new Vector3(1f, 1f, 1f); machine._isCrouching = false; } } if (jump_transition) { machine.StateChange(KeyValue, BasicControllerMachine.Aerial); jump_transition = false; return; } if (machine.Motor.Velocity.magnitude > 0f || machine._moveInputVector.magnitude > 0f) { machine.StateChange(KeyValue, BasicControllerMachine.Walking); return; } }