private void HandleAnimation() { _animator.SetFloat("MoveSpeed", _moveSpeed); _animator.SetBool("IsSprinting", _characterController.IsPlayerSprinting()); _animator.SetBool("OnGround", _characterController.IsPlayerOnGround()); _animator.SetBool("Jump", _characterController.DidPlayerJump()); _animator.SetBool("DoubleJump", _characterController.DidPlayerDoubleJump()); _animator.SetBool("WindAbility", _playerAbility.IsAbilityBeingPressed(Weather.Wind)); _animator.SetBool("FrostAbility", _playerAbility.IsAbilityBeingPressed(Weather.Frost)); _animator.SetBool("SunAbility", _playerAbility.IsAbilityBeingPressed(Weather.Sun)); _animator.SetBool("RainAbility", _playerAbility.IsAbilityBeingPressed(Weather.Rain)); }
/// <summary> /// This is called every frame by MyPlayer in order to tell the character what its inputs are /// </summary> public void SetInputs(ref PlayerCharacterInputs inputs) { // Clamp input Vector3 moveInputVector = Vector3.ClampMagnitude(new Vector3(inputs.MoveAxisRight, 0f, inputs.MoveAxisForward), 1f); // Set the character movement speed. Used for the animations _moveSpeed = Mathf.Abs(inputs.MoveAxisRight) + Mathf.Abs(inputs.MoveAxisForward); _moveSpeed = Mathf.Clamp(_moveSpeed, 0f, 1f); UpdateTargetDirection(ref inputs); if (moveInputVector != Vector3.zero && _lookDirection.magnitude > 0.1f) { var freeRotation = Quaternion.LookRotation(_lookDirection, transform.up); var differenceRotation = freeRotation.eulerAngles.y - transform.eulerAngles.y; var eulerY = transform.eulerAngles.y; if (differenceRotation < 0 || differenceRotation > 0) { eulerY = freeRotation.eulerAngles.y; } var euler = new Vector3(0, eulerY, 0); _currentRotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(euler), TurnSpeed * _turnSpeedMultiplier * Time.deltaTime); } // Move and look inputs _moveInputVector = _lookDirection; // cameraPlanarRotation * moveInputVector; // Jumping input if (inputs.JumpDown) { _timeSinceJumpRequested = 0f; _jumpRequested = true; } // Impulse/Wind Ability input if (_ability.IsAbilityBeingPressed(Weather.Wind)) { _timeSinceWindAbilityRequested = 0f; _windAbilityRequested = true; } // Sprint input //if (AllowSprint) //{ // if (!_sprintActivated && inputs.SprintHoldDown && _moveInputVector.magnitude > 0.1) // { // _maxMoveSpeed += SprintSpeedBoost; // _sprintActivated = true; // } else if (!inputs.SprintHoldDown) // { // _maxMoveSpeed = MaxStableMoveSpeed; // _sprintActivated = false; // } //} }