Search Unity

Scale time=0 Ok, but i want to pause some scripts also [Newb help]

Discussion in 'Scripting' started by qiqette, Feb 12, 2016.

  1. qiqette

    qiqette

    Joined:
    Feb 7, 2016
    Posts:
    121
    Title^
    When i pause the game i can still pressing "Fire 1" and the player still intantiating a bullet or prejumping.

    Thanks in advice <3
     
  2. pixpusher2

    pixpusher2

    Joined:
    Oct 30, 2013
    Posts:
    121
    Add a time scale check to your control code to prevent it from executing if it's zero:
    Code (CSharp):
    1. if (Time.timeScale > 0f && Input.GetButtonDown("Fire1"))
    2. {
    3.     // shoot
    4. }
     
    Kiwasi likes this.
  3. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    This works. However for most games you will want a delay timer on your shots. That way the players fire rate is not tied to their frame rate. With a delay timer pausing the game will work smoothly.
     
    qiqette and pixpusher2 like this.
  4. pixpusher2

    pixpusher2

    Joined:
    Oct 30, 2013
    Posts:
    121
    Good call! I've not done a shooter myself so it's something for @qiqette to take into consideration.
     
    qiqette likes this.