Question by
Zitoox · Oct 12, 2016 at 11:01 PM ·
scripting problemimageenablepause game
Pause Game and enable image
Hi! I am trying to make a script in JavaScript that pauses the game and then enables an UI Image when the player hits the collider, and then unpause the game and disable the UI Image when the player is not on the collider.
I am a scripting beginner, and i made this for now:
#pragma strict
var Img:UI.Image;
function OnTriggerEnter (o:Collider) {
Img.GameObject.SetActive (true);
if (Time.timeScale == 1.0)
Time.timeScale = 0.0;
else
Time.timeScale = 0.0;
}
function OnTriggerExit (o:Collider) {
Img.GameObject.SetActive (true);
if (Time.timeScale == 0.0)
Time.timeScale = 1.0;
else
Time.timeScale = 1.0;
}
I didn't get any error in making the game pause, but i get the following error:
I also wanted to know how to make the game wait 3 seconds and then unpause the game, because now i realised that it is impossible to get out of the trigger with the game paused xD Can someone help me on this one? Thanks =)
scripterror.png
(22.1 kB)
Comment