// Update is called once per frame void Update() { moveDirectionX = 0f; // Player character actions if (playerHealth.GetCanAct()) { moveDirectionX = Input.GetAxisRaw("Horizontal"); if (Input.GetButtonDown("Jump")) { playerMovement.Jump(); } if (Input.GetButtonUp("Jump")) { playerMovement.CutJumpHeight(); } if (Input.GetButtonDown("Transform")) { //playerMovement.StopiAllMovement(); transformationController.Transform(); } if (Input.GetButtonDown("LightAttack")) { if (transformationController.GetIsInNormalForm()) { meleeAttack.Attack(ActionType.lightMelee); } else { rangedAttack.Attack(ActionType.lightRanged); } } if (Input.GetButtonDown("HeavyAttack")) { if (transformationController.GetIsInNormalForm()) { meleeAttack.Attack(ActionType.heavyMelee); } } } playerMovement.MoveInDirection(moveDirectionX); // Interface controls if (Input.GetButtonDown("Cancel")) { screenManager.SetPauseMenuActive(); } }
public override void Move() { //Stop when ground attacking on ground and when doing the special attack if (attacksGround.cooldownCurr > attacksGround.cooldownTolerance || specialAttack.cooldownCurr > specialAttack.cooldownTolerance) { controller.Move(0, false); return; } //If the player was crouching, it will continue if there's a ceiling above him if (inputManager.crouch || (!inputManager.crouch && controller.IsOnCeiling() && keepCrouch)) { keepCrouch = true; //Applying crouch speed modifier inputManager.horizontalMove *= crouchSpeed; //Disabling the stand collider if on ground if (standCollider) { standCollider.enabled = false; } //Setting animator to crouch animator.SetBool("IsCrouching", true); } else { keepCrouch = false; //Enabling the stand collider if (standCollider) { standCollider.enabled = true; } //Setting animator to not crouch animator.SetBool("IsCrouching", false); } // Attack only if not crouching if (!keepCrouch) { if (inputManager.attack) { if (controller.IsOnGround()) { attacksGround.Attack(); } else { attacksAir.Attack(); } } else if (controller.IsOnGround() && inputManager.specialAttack) { specialAttack.Attack(); inputManager.specialAttack = false; } } //Can't jump when there's a ceiling directly above if (controller.IsOnCeiling()) { inputManager.jump = false; } //Filtering the jump input if (lastJumpInput && inputManager.jump) { inputManager.jump = false; } else { lastJumpInput = inputManager.jump; } //If the player isn't grounded, it can't double jump if (inputManager.jump && !controller.IsOnGround()) { //Moving it, without double jumping inputManager.jump = false; } // Moving controller.Move(inputManager.horizontalMove * Time.fixedDeltaTime, inputManager.jump); //Dash if not crouching if (!keepCrouch && inputManager.dash != 0) { controller.Dash(inputManager.dash == 1); inputManager.dash = 0; } }
private void FixedUpdate() { attack.Attack(); }