public void StartAttack(ComboState attack) { //StartComboAttacks(); animator.applyRootMotion = true; animator.SetBool(attack.ToString(), true); //animator.SetBool("Attack", true); //animator.SetBool("Attack 1", true); }
private void Update() { //animator.SetBool("Combo Finished", currentComboState == ComboState.None); switch (currentState) { case SimpleStateMachine.Idle: HandleInputs(); moveDirection = GetMoveDirection(movementInput); SetGravity(); if (moveDirection.x != 0f && moveDirection.z != 0f) { currentState = SimpleStateMachine.Moving; //if (characterController.velocity.y < -1f) // currentState = SimpleStateMachine.Falling; //else // currentState = SimpleStateMachine.Moving; } if (jumpInput && isGrounded) { Jump(); currentState = SimpleStateMachine.Jumping; } if (dashInput) //Add a flag for canDash { currentState = SimpleStateMachine.Dashing; } if (lightAttackInput) { StartAttack(currentComboState); currentState = SimpleStateMachine.Attacking; } characterController.Move(moveDirection * Time.deltaTime); break; case SimpleStateMachine.Moving: HandleInputs(); moveDirection = GetMoveDirection(movementInput); if (moveDirection.x == 0f && moveDirection.z == 0f) { currentState = SimpleStateMachine.Idle; } SetGravity(); if (jumpInput && isGrounded) { Jump(); currentState = SimpleStateMachine.Jumping; } if (dashInput) { currentState = SimpleStateMachine.Dashing; } if (lightAttackInput) { StartAttack(currentComboState); currentState = SimpleStateMachine.Attacking; } characterController.Move(moveDirection * Time.deltaTime); break; case SimpleStateMachine.Jumping: HandleInputs(); moveDirection = GetMoveDirection(movementInput); SetGravity(); characterController.Move(moveDirection * Time.deltaTime); if (isGrounded) { currentState = SimpleStateMachine.Moving; } if (dashInput) { currentState = SimpleStateMachine.Dashing; } break; case SimpleStateMachine.Dashing: Dash(); if (dashingTime >= dashlength) { dashingTime = 0f; currentState = SimpleStateMachine.Moving; } break; case SimpleStateMachine.Attacking: HandleInputs(); //ComboAttacks(); //ResetComboState(); if (animator.GetBool(currentComboState.ToString()) == false) //if(ComboFinishedTest()) { //animator.applyRootMotion = false; currentState = SimpleStateMachine.Moving; } break; case SimpleStateMachine.Falling: HandleInputs(); break; } }