示例#1
0
    private void PlayMovementAnimations(bool jumping, bool falling, bool crouch, bool melee, bool rolling, float xVelocity)
    {
        if (Animator != null)
        {
            Animator.SetBool("Jumping", jumping);
            Animator.SetBool("Falling", falling);
            Animator.SetBool("Crouching", crouch);
            Animator.SetBool("Melee", melee);
            Animator.SetBool("Roll", rolling);
            _weaponManager.ToggleWeaponActiveStatus(!rolling && !melee);

            // The only time we want to be playing the run animation is if we are grounded, not holding the left trigger (or left ctrl), and not crouching nor pointing exactly upwards
            var finalXVelocity = Math.Abs(xVelocity) * VelocityBasedOffInput(crouch, jumping, falling);
            Animator.SetFloat("xVelocity", finalXVelocity);

            // Also inform the weapon animator that we are crouching
            _weaponManager.AnimateWeapon("Crouch", crouch);

            ChangeBoxColliderBasedOffActionMovement(crouch);

            // We want to hold still if any movement (even just pointing at different angles) is happeneing
            var holdStill = (Input.GetKey(InputManager.Instance.LockMovement) || Input.GetAxis(JoystickId + GameConstants.Input_LTrigger) >= 1 || finalXVelocity > 0 || crouch || jumping || falling || _meleeActive);
            _weaponManager.AnimateWeapon("HoldStill", holdStill);
        }
    }