- Home /
how to pause time when hit an object
hi everyone how to i pause time for a few seconds when i hit an object? i have a timer script:
function Awake() {
startTime = Time.time;
}
function OnGUI () {
GUI.skin = guiSkin; //make sure that your time is based on when this script was first called //instead of when your game started var guiTime = Time.time - startTime;
restSeconds = countDownSeconds - (guiTime);
//display messages or whatever here -->do stuff based on your timer
if (restSeconds == 60) {
print ("One Minute Left");
}
if (restSeconds == 0) {
print ("Time is Over");
restSeconds = 0;
}
//display the timer
roundedRestSeconds = Mathf.CeilToInt(restSeconds);
displaySeconds = roundedRestSeconds % 60;
displayMinutes = roundedRestSeconds / 60;
text = String.Format ("{0:00}:{1:00}", displayMinutes, displaySeconds);
GUI.Label (Rect (500, 60, 300, 100), text);
}
i found a pause object script:
function PauseWaitResume (pauseDelay : float) {
Time.timeScale = .0000001;
yield WaitForSeconds(pauseDelay * Time.timeScale);
Time.timeScale = 1.0;
}
Comment
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Time.time explanation. 1 Answer
Timescale help 1 Answer
Play a particle system when Time.timeScale = 0? 0 Answers
Delaying through yield 2 Answers