Search Unity

Is there a way to speed up the game more than 100 times?

Discussion in 'Scripting' started by Ayham4CG, Oct 13, 2019 at 12:52 AM.

  1. Ayham4CG

    Ayham4CG

    Joined:
    Aug 19, 2019
    Posts:
    16
    I want that when the game starts to run on high speed very quickly and a high physical frame rate to cover the time when the game was closed To make her look like it was working all the time non-stop. And then back to the actual time and normal speed any help please?
     
  2. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    4,522
    Depends on what kind of game you're talking about.

    In general, without knowing anything about your game: You need to separate your simulation from your presentation, which means you can run your game logic systems in the background without showing the results on the screen. When you're exiting, you need to write your game state to a persistent storage, when you start up your game, you need to load up. You also need to store the current time and when you start up, you calculate the time between these two.
    Now, under a cover of a loading screen you start to run your simulation alone without showing the results until the simulation arrives to present time. When it happens, you load this whole state into the presentation as well, so you show the game.
    This means you need to separate your simulation (game logic systems) from the presentation (sprites/meshes/visible game world) and you cannot rely on anything which needs visual representation for game logic.

    It can be complicated, depending on the type of game we're talking about, but for example big open world games usually do this when you fast travel or you enter to area where you weren't a while.
    Like Skyrim for example.
     
    Ayham4CG and MNNoxMortem like this.
  3. Ayham4CG

    Ayham4CG

    Joined:
    Aug 19, 2019
    Posts:
    16
    Hi, thank you this was really helpful
    it's a sims game like (SimCity, The Guild 2,etc)
    I have divided the game into data/logic/view layers
    and i need to run data/logic at high speed in the loading screen
    The way I found it by changing the (time scale_, the normal value is (1)
    But this value cannot be increased by more than (100)
    the problem is if the player close the game for 24 H for example
    and when he back , with this speed (timescale = 100)
    it need 15 min in the loading screen to calculate the 24 hours x.x
     
  4. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,102
    When you run calculation in your data and logic layers, you are (probably) using some time multiplier (usually Time.deltaTime) do have things running in real time terms (eg money per second)

    Just run the data and logic a single time with a value of 24 hours, instead of a single frame duration (deltaTime is approx 0.016s, depending on framrate)
     
    Ayham4CG likes this.
  5. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    5,743
    @Ayham4CG,
    We briefly discussed this topic recently, so I know where you come from with a question.
    https://forum.unity.com/threads/how...he-background-on-android.755699/#post-5053904

    It will be really easier to fetch data from the server, on current game state, rather than ask player, to wait x minutes, to load screen. Is irrational attempt, and you kill your app on the spot. Specially on mobiles, where things should be casual.

    You really should rethink your design. Even better, play some similar games, and think, how they resolve such matters, when you play game few days, few weeks etc.

    When you consider deterministic fast forward, you really want to reduce amount of data, to be processed.
    More on that, you may need consider DOTS, to such become more feasible for prolong duration as 24 hours.

    Again, I suggest go back to drawing board and rethink whole concept of processing data for your game and potential player experience.

    However, if game is not physics based, and you can run as fast as possible (without DOTS), you can put logic into while loop, until is loaded. But that can freeze app. So need be careful.
     
    Ayham4CG likes this.
  6. WhipJr

    WhipJr

    Joined:
    Aug 3, 2011
    Posts:
    100
    usually when i have to run something like this, I have found the best way is to track when the app is closed, and upon loading, compare closed time to current time to get a time difference, then work off of that time difference to get current values.
     
    Ayham4CG likes this.
  7. Ayham4CG

    Ayham4CG

    Joined:
    Aug 19, 2019
    Posts:
    16
    Thank you all I really got a great benefit from all the answers !