Hi Guys,
I am currently having issues with trying to “temporarily” slow down time after the player is hit. I have read around the forums and answers and can’t figure out why my code isn’t working.
//These Methods are in the same Class..
public void TakeDamage(int atkdmg, int animeControllerNum) {
hurtIdentifier = animeControllerNum;
currentHealth -= atkdmg;
healthSlider.value = currentHealth;
_tookDamage = true;
timeScaleTimer = scaleTimerVal; // (scaleTimerVal set to 2f) to set the timer to control when the game should go back to regular 1f time scale
_turnSlowMoOn = true;
}
void Update() {
timeScaleTimer -= Time.deltaTime;
if (timeScaleTimer <= 0) {
timeScaleTimer = 0;
_turnSlowMoOn = false;
}
if (_turnSlowMoOn) {
if (Time.timeScale == 1f) {
Time.timeScale = .5f;
}
else {Time.timeScale = 1f;
Time.fixedDeltaTime = .02f * Time.timeScale;
}
}