Question by
peczonalex · Jun 04, 2020 at 03:38 PM ·
script.timer
I made a slow mo for my game and a timer for it with text. but the timer multiplies times 2 ever time i use slow mo.
//apologies beginer at making my own code.
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class slowtime : MonoBehaviour {
[SerializeField] Text countDown;
private float currentTime = 0f;
private float slowTime = 10f;
// put cooldown for 30 secounds
private bool slowEnded;
private bool slowStarted;
public void Update()
{
slowEnded = true;
currentTime -= 1 * Time.deltaTime;
countDown.text = currentTime.ToString("0");
if (Input.GetKeyUp(KeyCode.X) && slowEnded == true)
{
currentTime = slowTime;
slowEnded = false;
currentTime = UnityEngine.Time.time;
Time.timeScale = 0.25f;
}
if (currentTime <= 0.0f )
{
currentTime = 0;
slowEnded = true;
timerEnded();
}
}
void timerEnded()
{
Time.timeScale = 1;
}
}
Comment
Your answer
Follow this Question
Related Questions
Death Countdown Area 0 Answers
Timer Board. 1 Answer
Make an Object Stop Moving Upon Collision 0 Answers
Why is the code below not setting the value for the timer? 0 Answers
cant add script 2 Answers