public void UpdateBashCommon() { // RAMP VELOCITY TO ZERO //if (vel.sqrMagnitude > 0.5f) { // vel *= bashSpeedFalloffMult; //} else { // vel = Vector2.zero; //} // FIND TARGET var bashTar = Physics2D.OverlapCapsule(super.body.position + bashCollider.offset, bashCollider.size, bashCollider.direction, 0, ~(1 << 8) /*player*/); bashTarget = (bashTar && bashTar.tag == "Projectile") ? bashTar.transform : null; // COOLDOWN if (bashCooldown > 0) { bashCooldown -= Time.fixedDeltaTime; } if (bashTarget) { // MOVE ARROW bashArrow.position = bashTarget.position; bashArrow.localRotation = Quaternion.Euler(0, 0, bashAngle); // START BASH if (InputWrapper.GetBash() && !bashInit && bashCooldown <= 0) { bashInit = true; super.mode = MoveMode.BASH; bashTimeStarted = Time.unscaledTime; } } var isBash = super.mode == MoveMode.BASH; if (!isBash) { bashInit = false; } bashArrow.gameObject.SetActive(isBash); // SET BULLET TIME Time.timeScale = isBash ? 0.01f : 1; Time.fixedDeltaTime = Time.timeScale * super.initFixedDeltaTimescale; }
public Vector2 Update() { if (!bashTarget || super.mode != MoveMode.BASH) { return(Vector2.zero); } // SET DIRECTION var input = new Vector2(super.horz, super.vert); if (input.sqrMagnitude != 0) { var mouseAng = Vector2.SignedAngle(Vector2.up, input); if (Time.unscaledTime - bashTimeStarted < bashTimeSetupMax) // initial angle { bashAngle = mouseAng; } else { bashAngle = Mathf.MoveTowardsAngle(bashAngle, mouseAng, bashSetupRate * Time.fixedDeltaTime); } } // PERFORM BASH if (!InputWrapper.GetBash() || Time.unscaledTime - bashTimeStarted > bashTimeMax) { DoBash(); super.mode = MoveMode.STANDARD; } else { vel = Vector2.zero; } return(vel); }