// Update is called once per frame void Update() { //Debug.Log("cur state: " + _motor.motorState); if (_motor.motorState == PlatformerMotor2D.MotorState.OnGround) { _animator.SetBool("ground", true); } if (_motor.motorState == PlatformerMotor2D.MotorState.Jumping || _isJumping && (_motor.motorState == PlatformerMotor2D.MotorState.Falling || _motor.motorState == PlatformerMotor2D.MotorState.FallingFast)) { _isJumping = true; _animator.Play("Jump"); _animator.SetBool("ground", false); if (_motor.velocity.x <= -0.1f) { _currentFacingLeft = true; } else if (_motor.velocity.x >= 0.1f) { _currentFacingLeft = false; } Vector3 rotateDir = _currentFacingLeft ? Vector3.forward : Vector3.back; visualChild.transform.Rotate(rotateDir, jumpRotationSpeed * Time.deltaTime); } else { _isJumping = false; visualChild.transform.rotation = Quaternion.identity; if (_motor.motorState == PlatformerMotor2D.MotorState.Falling || _motor.motorState == PlatformerMotor2D.MotorState.FallingFast) { //_animator.Play("Fall"); } else if (_motor.motorState == PlatformerMotor2D.MotorState.WallSliding || _motor.motorState == PlatformerMotor2D.MotorState.WallSticking) { //_animator.Play("Cling"); } else if (_motor.motorState == PlatformerMotor2D.MotorState.OnCorner) { //_animator.Play("On Corner"); } else if (_motor.motorState == PlatformerMotor2D.MotorState.Slipping) { //_animator.Play("Slip"); } else if (_motor.motorState == PlatformerMotor2D.MotorState.Dashing) { //_animator.Play("PlayerSlide"); //_animator.SetTrigger("slide"); } else if (_motor.motorState == PlatformerMotor2D.MotorState.NormalWave) { //_animator.SetTrigger("wave"); } else if (_motor.motorState == PlatformerMotor2D.MotorState.JumpWave) { //_animator.SetTrigger("jumpWave"); _motor.EndJumpAttack(); } else if (_motor.motorState == PlatformerMotor2D.MotorState.NormalThrow) { //_animator.SetTrigger("throw"); //_animator.Play("PlayerThrow"); } else if (_motor.motorState == PlatformerMotor2D.MotorState.JumpThrow) { //_animator.SetTrigger("jumpThrow"); //_animator.Play("PlayerJumpThrow"); _motor.EndJumpAttack(); } else { if (_motor.IsOnLadder()) { _animator.SetBool("isOnLadder", true); } else { _animator.SetFloat("speed", _motor.velocity.sqrMagnitude); _animator.SetBool("isOnLadder", false); } if (_motor.velocity.sqrMagnitude >= 0.1f * 0.1f) { _animator.Play("Walk"); } else { _animator.Play("Idle"); } } } // Facing float valueCheck = _motor.normalizedXMovement; if (_motor.motorState == PlatformerMotor2D.MotorState.Slipping || _motor.motorState == PlatformerMotor2D.MotorState.Dashing || _motor.motorState == PlatformerMotor2D.MotorState.Jumping) { valueCheck = _motor.velocity.x; } if (Mathf.Abs(valueCheck) >= 0.1f) { Vector3 newScale = visualChild.transform.localScale; newScale.x = Mathf.Abs(newScale.x) * ((valueCheck > 0) ? 1.0f : -1.0f); visualChild.transform.localScale = newScale; } }