public override void AfterCharacterUpdate(float deltaTime) { // Detect being stopped by elapsed time if (!_isStopped && _timeSinceStartedCharge > MaxChargeTime) { _mustStopVelocity = true; _isStopped = true; } // Detect end of stopping phase and transition back to default movement state if (_timeSinceStopped > StoppedTime) { AssignedCharacterController.TransitionToState(AssignedCharacterController.DefaultMovementState); } }
public override void AfterCharacterUpdate(float deltaTime) { switch (_climbingState) { case ClimbingState.Climbing: // Detect getting off ladder during climbing ActiveLadder.ClosestPointOnLadderSegment(KinematicCharacterMotor.TransientPosition, out _onLadderSegmentState); if (Mathf.Abs(_onLadderSegmentState) > 0.05f) { _climbingState = ClimbingState.DeAnchoring; // If we're higher than the ladder top point if (_onLadderSegmentState > 0) { _targetPosition = ActiveLadder.TopReleasePoint.position; _targetRotation = ActiveLadder.TopReleasePoint.rotation; } // If we're lower than the ladder bottom point else if (_onLadderSegmentState < 0) { _targetPosition = ActiveLadder.BottomReleasePoint.position; _targetRotation = ActiveLadder.BottomReleasePoint.rotation; } } break; case ClimbingState.Anchoring: case ClimbingState.DeAnchoring: // Detect transitioning out from anchoring states if (_anchoringTimer >= AnchoringDuration) { if (_climbingState == ClimbingState.Anchoring) { _climbingState = ClimbingState.Climbing; } else if (_climbingState == ClimbingState.DeAnchoring) { AssignedCharacterController.TransitionToState(AssignedCharacterController.DefaultMovementState); } } // Keep track of time since we started anchoring _anchoringTimer += deltaTime; break; } }