private void DoDash(FacingDir dir) { if (inDashCooldown) { return; } if (wallStick != null && wallStick.Doing) { return; } if (!physics.Grounded) { if (!canAirDash || didAirDash) { return; } horizontalMovement.SetSpeed(dashSpeed); } StartCoroutine(DashCooldown()); ChangeState(AbilityStates.Doing); curDashTime = 0.0f; dashDir = dir; }
public virtual void OnJumpPress() { if (wasWallStickingLeft || wasWallStickingRight) { StartCoroutine(HandleWallJumpAcceleration()); Vector2 vWallJump = wallJump; if (dash != null && dash.HoldingDash) { vWallJump = dashWallJump; if (horizontalMovement != null) { horizontalMovement.SetSpeed(dash.DashSpeed); } } var dir = Mathf.Sign(physics.TargetVelocity.x); if (faceable != null) { dir = faceable.CurFacingDir() == FacingDir.Right ? 1 : -1; } physics.SetVelocity(new Vector2(-(vWallJump.x * dir), vWallJump.y)); wasWallStickingLeft = wasWallStickingRight = false; return; } var grounded = physics.Grounded; // Handle jumping from ground if (grounded || canCoyoteJump) { physics.SetVelocityY(jumpForce); return; } // Handle double jumping if (canDoubleJump && !grounded && !didDoubleJump) { didDoubleJump = true; physics.SetVelocityY(doubleJumpForce); } }