// Update is called once per frame void Update() { transform.position += _currentMoveVector * currentSpeed * Time.deltaTime; transform.rotation = Quaternion.Lerp(transform.rotation, _currentLookRotation, 0.99f * Time.deltaTime * lerpSpeed); currentDistortion = Mathf.Lerp(currentDistortion, 15.0f, 0.99f * Time.deltaTime * 5.0f); SetLensDistortion(currentDistortion); if (Time.time - timeSinceDash >= 0.15f) { currentSpeed = speed; dash = false; dashTrail.StopTrail(); } }
private void FixedUpdate() { if (!dashing && !charging) { rb.velocity = direction * speed; //Velocity is the product of the set speed with the raw Axis Input currentCharge = 0f; if ((deltatime > 0.3f) && (direction != Vector2.zero)) { switch (theme) { case "ice": source.PlayOneShot(moveSand, 1.0f); break; case "grass": source.PlayOneShot(moveGrass, 1.0f); break; case "beach": source.PlayOneShot(moveSand, 1.0f); break; default: source.PlayOneShot(moveGrass, 1.0f); break; } deltatime = 0.0f; } deltatime += Time.deltaTime; } else if (charging) { rb.velocity = direction * speed * dashSlow; //The Character is slowed,per default by 25% currentCharge = currentCharge + (chargeRatePerSecond / 50); //Charge goes up by 0.25 in one Second _uiController.DashLevelOne.fillAmount = currentCharge; if (currentCharge >= 1 && currentCharge < 2) { _uiController.DashLevelOne.fillAmount = 1f; _uiController.DashLevelTwo.fillAmount = currentCharge - 1f; } else if (currentCharge >= 2 && currentCharge < 3) { _uiController.DashLevelTwo.fillAmount = 1f; _uiController.DashLevelTwo.fillAmount = 1f; _uiController.DashLevelThree.fillAmount = currentCharge - 2f; } else if (currentCharge >= 3) //The Current Charge can not go over 3 { currentCharge = 3; _uiController.DashLevelThree.fillAmount = 1f; charging = false; dashing = true; } } else if (dashing) { animator.SetBool("dashing", true); if (currentCharge >= 1 && currentCharge < 2) { Dash(dashMultiplierLevelOne, 1); } else if (currentCharge >= 2 && currentCharge < 3) { Dash(dashMultiplierLevelTwo, 2); } else if (currentCharge == 3) { Dash(dashMultiplierLevelThree, 3); } else { // Break, if charge not big enough animator.SetBool("dashing", false); animator.SetBool("charging", false); dashing = false; currentCharge = 0f; _uiController.DashLevelOne.fillAmount = 0f; _uiController.DashLevelTwo.fillAmount = 0f; _uiController.DashLevelThree.fillAmount = 0f; } } if (lastFrameDashing && !dashing) { _dashTrail.StopTrail(); } if (!lastFrameDashing && dashing) { _dashTrail.StartTrail(); } lastFrameDashing = dashing; lastFrameDashing = dashing; }