Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bullet time Matrix style

Discussion in 'Scripting' started by Alexo, May 8, 2007.

  1. Alexo

    Alexo

    Joined:
    Feb 26, 2007
    Posts:
    34
    Hello guys

    I want to make an effect like the bullet time in Matrix (like Max Paine too). But I dont know how to slowdown the time without affecting the framerate (I mean I want the framerate keep being high while the objects slow down).

    I work with physics a lot and I should slowdown all the objects, making them restart (after the bullet time) with the same physic properties (Velocity, Forces, etc)

    Should I act on timeScale or fixedDeltaTime or what?
     
  2. David-Helgason

    David-Helgason

    Moderator

    Joined:
    Mar 29, 2005
    Posts:
    1,104
  3. Foxxis

    Foxxis

    Joined:
    Jun 27, 2006
    Posts:
    1,108
    Sorry to do gravedigging here, but I manage to freeze Unity by setting Time.fixedDeltaTime = 0. Is that prohibited, or should I go looking elsewhere for the problem...?

    TIA! :)

    (Edit: Wasn't as far out in the graveyard as I thought, assumed the thread was ancient.. :) )
     
  4. Foxxis

    Foxxis

    Joined:
    Jun 27, 2006
    Posts:
    1,108
    ...and a small followup question:

    What if I want to pause a game (which involves physics), but still be able to use framerate independent UI elements (that rely on Update and Time.deltaTime)?
     
  5. Foxxis

    Foxxis

    Joined:
    Jun 27, 2006
    Posts:
    1,108
    It seems I do lots of replying to my own posts... :)

    I can see why it's problematic to set fixedDeltaTime = 0, as it's the interval between fixedupdate-calls.
    (However, the docs advices to *lower* the value when you lower timeScale...is that really right?)

    Anyway, setting a higher value for fixedDeltaTime at first gives the impression that it pauses the physics engine, but it doesn't. When the value is set back to default (0.02?), the solution jumps to a new state (which has been reached "behind the scenes").

    So I assume pausing physics is done in another way. I'll search a bit as it must have been discussed before.
     
  6. Alexo

    Alexo

    Joined:
    Feb 26, 2007
    Posts:
    34
    TimeScale = 0 --> FixedUpdate() (that is where you code physics driven object) isn’t executed --> game goes in pause!

    You put graphic objects (the ones you want to keep move, like cameras), into Update() and use Time.realtimeSinceStartup to get the running time, since it isn’t affected by TimeScale


    Am I right guys?
     
  7. Foxxis

    Foxxis

    Joined:
    Jun 27, 2006
    Posts:
    1,108
    Yep.
    Thanks for the realtimeSinceStartup variable - had overlooked that. Using it to increment stuff in Update() means the UI can still be framerate independent while the game itself if paused. Nice. :)
     
  8. Alexo

    Alexo

    Joined:
    Feb 26, 2007
    Posts:
    34
    u're welcome