Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

help with script

Discussion in 'Scripting' started by 6263osnova, Oct 14, 2014.

  1. 6263osnova

    6263osnova

    Joined:
    Oct 14, 2014
    Posts:
    31
    Hi guys.
    tell me how to make a frozen screen when you press
    (Example: I go to the trigger, I press the button "E", the text appears and the game freezes, and when it disappears, the game unfreezes)


    Code (JavaScript):
    1. var playerObject : GameObject;
    2. var message : String = "";
    3. var displayTime : float = 3;
    4. var displayMessage : boolean = false;
    5. var sound : AudioClip;
    6. var audioS : AudioSource;
    7. function Update() {
    8.     displayTime -= Time.deltaTime;
    9.     if (displayTime <= 0.0) {
    10.         displayMessage = false;
    11.     }
    12. }
    13. function OnTriggerStay(other : Collider) {
    14.     if(other.collider.gameObject == playerObject && Input.GetKeyDown(KeyCode.E)&& !audio.isPlaying){
    15.        audio.Play();
    16.        displayMessage = true;  
    17.        displayTime = 1.0;
    18.        
    19.     }
    20. }
    21. function OnGUI () {
    22.     if (displayMessage) {
    23.         GUI.Label(Rect(Screen.width/2 - 250, Screen.height- 100,700,50),"The lock is broken. I can't open the door.");
    24.  
    25.     }
    26. }


    tried to Time.timeScale = 1; but do not know how to unfreeze
    thanks in advance!:)
     
  2. sam268

    sam268

    Joined:
    Apr 21, 2014
    Posts:
    149
    No do Time.timeScale = 0; to pause.
     
  3. 6263osnova

    6263osnova

    Joined:
    Oct 14, 2014
    Posts:
    31
    I put 0, the game freezes, but not defrosted
     
  4. sam268

    sam268

    Joined:
    Apr 21, 2014
    Posts:
    149
    defrost? like unpause? Just turn the timeScale back to 1
     
  5. 6263osnova

    6263osnova

    Joined:
    Oct 14, 2014
    Posts:
    31
    can help me with this?
    I did not go out, or I'm doing something wrong