Search Unity

pausing game - restarting from other button

Discussion in 'Scripting' started by yangmeng, Sep 22, 2007.

  1. yangmeng

    yangmeng

    Joined:
    Dec 5, 2006
    Posts:
    573
    When using a button to pause a game, it seems that only that button is still functional and other game objects will not function until Time.timeScale has been set to something other than zero. Is that correct? Is there a way to have other buttons be functional once the game is paused?
    Also, can anyone point me to some info on how OnApplicationPause would be used? I wasn't able to figure out just what it does or how to use it in a script.
    Thanks.
     
  2. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    Hi Yangmeng
    Im pretty sure OnMouse events are still called,
    HTH
    AC
     
  3. yangmeng

    yangmeng

    Joined:
    Dec 5, 2006
    Posts:
    573
    Maybe I did something wrong then. I'll try testing some more. Thanks.
     
  4. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,268
    There are still some issues with timescale and mouse events right now. I started a thread on the subject here.
     
  5. yangmeng

    yangmeng

    Joined:
    Dec 5, 2006
    Posts:
    573
    Thanks. I read the thread over. Convinced me to stick with the workaround I'm using (setting the timeScale really slow) until I hear things have changed...
     
  6. Foxxis

    Foxxis

    Joined:
    Jun 27, 2006
    Posts:
    1,108
    I ended up coding my own pause system, which gives me the bonus of using physics while paused. I basically have a gamecontroller object which keeps track of lots of things, one is pause. If the player pauses the game (or enters a paused mode, my game is pretty special :) ), it sends messages to the affected objects (it keeps several arrays of different kinds of objects).
    The objects then store their current physics state (velocity, angular velocity, etc), and stops performing updates during FixedUpdate. When the "go" command later is recieved, everything is done in reverse order.

    It's a great workaround, and as I said, all "eye candy effect" - even those using physics - keeps running while "paused". :)