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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

[Released] Rewind Time Manager

Discussion in 'Assets and Asset Store' started by V0odo0, Sep 10, 2012.

  1. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    327
    Hello friends!

    Yesterday, I finished work on a new tool for Unity3d. Here is it! ;)


    Rewind Time Manager is a tool that allows you to manage the time in Play Mode. This tool will allow Unity3d developers to create a game in which you can rewind time back such as in games like Braid or Prince of Persia: The Sands of Time. The tool is simply records the data on changes in object properties and not used Time class (In particular Time.timeScale).


    Currently supports recording and playback in reverse:

    • Transform of the objects (Position, Rotation and Scale)
    • Force and direction of Rigidbodies
    • Animations
    • Sounds (At the moment only looped sound)
    • Custom floating-point numbers
    Comments are welcome.
     
  2. bug5532

    bug5532

    Joined:
    Aug 16, 2011
    Posts:
    307
    Just spotted it in the asset store earlier. Looks perfect for my next game :) will definitely be purchasing this soon!
     
  3. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    327
    bug5532 Thx ;)

    I forgot to ask: What components or parameters in your opinion should be supported in addition to that specified?
     
  4. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    327
    Only on this week! 80% OFF!
     
  5. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    Haha, looks pretty awesome! Bookmarked!

    EDIT: Would be nice if you add the PAUSE FUNCTION.
    Also, is there anyway to speed up or slow down the rewind?
     
    Last edited: Oct 10, 2012
  6. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    It seems you can only rewind up until the last point you rewinded. In Braid you can rewind everything no matter what if I remember correctly. Would that be possible here? And if not, why?
     
  7. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    327
    I am da bawss,Thx ;) The pause function will be added in the future version.

    TwiiK, Sure it possible! I'll try to realiize it in the future version.
     
  8. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    Really? YOU GOT MY MONEY! INSTANT BUY! :D

    Another thing, do you record ALL properties of object while simulation is running? I am thinking this could evolve into a recorder like function too (like Battlefield 2's Battle Recorder), and perhaps as a side function, a save game capability (since you are recording all properties).
     
    Last edited: Oct 12, 2012
  9. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    For $2 it is a steal. :p

    Played around a bit with it. Not sure I understand the accuracy setting at the moment, but maybe I will once I look at the code. Is it how often it records data? I didn't see a difference when I changed it.

    A few comments in the code would be gravy, but for $2 I'm not going to make demands. :D

    Literally took me 10 seconds to set up in a completely new scene. That's really cool.

    The only thing I didn't like was the custom float approach. That seems really rigid. I'm sure I will need to be able to rewind a lot of custom things in my games like for instance lights switching on and off, custom effects, particles etc. I would like a more api based approach where you can feed your data to a method or something. Have you thought about expanding on that bit?
     
  10. Xeir

    Xeir

    Joined:
    Oct 21, 2007
    Posts:
    342
    Couldn't pass this up for the price. I see a lot of uses and growth potential for it. Thanks!!
     
  11. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    327
    I am da bawss,

    The performance will be lower If record all parameters. Only the basic parameters is recorded (position, rotation, scale, rigidbody velocity and animation points). But you can set necessary parameters into custom float array. And yes, the data can be used to create a save function. I will write about this in documentation.

    TwiiK,

    Accuracy is the value that determines interval between data record:

    High – Record every 0.1 seconds
    Medium – Record every 0.5 seconds
    Low – Record every 1 second

    As for custom settings, I'll try to come up with something.
     
  12. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    I see. And then your interpolate between the recorded data to make it look smooth? That's why I couldn't tell at first, but I can clearly tell now. :)
     
  13. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    Bought! :D
    Question, can this be apply on per-object basis? or even per layer or per group basis? Eg. I only want certain entity to be affected by the rewind, NOT the whole game world. For example - like in the game "Singularity" where you can target enemy or object to be affected by your rewind effect. So let's say couple of barrels exploded, but I only want the remain of the barrel I am targeting to rewind back in time. Can this be done?
     
    Last edited: Oct 13, 2012
  14. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,237
    Bought! Thanks, looking forward to playing around with it. :)
     
  15. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    It's already per object. You add the RewindUnit.cs script component to whatever you want to be able to rewind.

    I would assume that to make it work per layer would be fairly straight forward by just writing a small script that adds this component to all objects in a layer at runtime.
     
  16. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    327
    Version 1.1 is now avaliable!

    New features:

    * Added freeze time function
    * Added custom boolean array
     
  17. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    That's great, although I'm already knee deep in messing up my copy of the code. :p

    I bought a lecture by Jonathan Blow from GDC about the time rewind implementation in Braid. Trying to wrap my head about how to implement all those features and make it as robust as it is in Braid. Recording once every 0.1s isn't enough for me, currently trying to make it record every frame and work my way from there. :p

    I have two questions:

    Why is RewindData made visible in the inspector in this version?
    Code (csharp):
    1. //[System.NonSerialized]
    2. public RewindTimeData[] RewData;
    Why do you story rigidbody.velocity.magnitude, and twice?
    Code (csharp):
    1. for (int i = 0; i < RewData.Length - 1; i++)
    2. {
    3.     RewData[i].ThisPos = RewData[i + 1].ThisPos;
    4.     RewData[i].ThisRot = RewData[i + 1].ThisRot;
    5.     RewData[i].ThisScale = RewData[i + 1].ThisScale;
    6.     RewData[i].ThisRigMagnitue = RewData[i + 1].ThisRigMagnitue; // Here
    7.  
    8.     RewData[i].JustInstantiated = RewData[i + 1].JustInstantiated;
    9.     RewData[i + 1].JustInstantiated = false;
    10.  
    11. }
    12. if (gameObject.GetComponent<Rigidbody>() != null)
    13. {
    14.     for (int i = 0; i < RewData.Length - 1; i++)
    15.     {
    16.         RewData[i].ThisRigVelocity = RewData[i + 1].ThisRigVelocity;
    17.         RewData[i].ThisRigMagnitue = RewData[i + 1].ThisRigMagnitue; // And here
    18.         RewData[i].ThisRigAngVelocity = RewData[i + 1].ThisRigAngVelocity;
    19.     }
    20. }
     
  18. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    327
    A little update:

    v1.2
    * Some fixes
    * New functions: StartRecord(); StopRecord();
     
  19. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    736
    Hi,

    i have already done my project with orbit camera,animation and many other things,can i use your package just drag and drop and some little change.

    Dev
     
  20. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    327
    Hi,

    Sure you can. All you need is to attach components to objects.

    Please read the documentation for more details:

    https://dl.dropboxusercontent.com/u/56229940/RTM Documentation.pdf
     
  21. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    736
  22. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    2 question please
    one is way only loop sound ?
    and second is possible to do replay with him
     
  23. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    327
    Hi,

    At the moment only loop sound supported. I will implement recording sound events in the next ver.
    For making replay use special tools from Asset Store.
     
  24. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    Hi, love this tool, but I have 2 questions..
    1)
    I use StartRecord after level loads, then StartRewind and StartRecord when my game time is going backwards or forwards....
    also tried just using StartRewind and StopRewind, but behavior seems the same, see below...

    If I quickly rewind, play, then rewind again, I noticed that the initial rewind data is gone...
    for example... record 5 seconds of gameplay. rewind 1 second (so buffer should now be 4 seconds long), then play for another second (rewind buffer should now be 5 seconds long again) rewind again, but its only 1 second long ???
    It seems like the buffer is reset every time after a partial rewind ? Is this a setting, or is there a way to stop this behavior please ?

    2) while player is re-winding, I hit the end of my rewind buffer... (5 seconds) but the rewinder freezes all objects at that time (while player holds rewind button)... but I want game to start forward play and start recording again once the rewind buffer is empty, is there feedback from the rewinder that lets me know player got to the end of the buffer please ?

    thanks
     
    Last edited: Feb 2, 2014
  25. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    sème for question 2 need know when rewinder is ending for restart recording automatique in code please helps
     
  26. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    327
    Hi guys, sorry for the late answer.

    JonnyHilly,
    1. Unfortunately yes, older recorder data is clearing after start rewinding. I know about this snag and will try to find a way to fix this
    2. You can count the time after start rewinding and use StopRewind() when this time is come to RewindDuration and disallow player to start rewind again

    kilik128,
    Take a look at 159 code line in RewindManager.cs
     
  27. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    Have you had any luck in fixing #1 ?

     
  28. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    is there any update on fixing #1 please ?

     
  29. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    12,917
    Great one, i can think of many uses already
     
  30. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    Voodoo, ok I solved issue #1 ... plus made a big speed up.

    Here is the solution, hopefully this makes sense, and you can implement it also, and share with others who purchased.

    1. in rewind unit, instead of shifting your entire array up each time... just use a ring buffer instead (much faster)... start at the beginning of your buffer, store a position, increment the store index (keep the index global in in rewind manager) if you get past the end of the array, loop the index back to element 0, so its constantly recording. (and all rewind units use the same index from rewindManager)

    2. when you rewind, just rewind back from the current index (reverse direction of index decrement instead of inc). Then, when you stop rewinding, just continue storing from where the current index rewound to (go back to incrementing). "Never" reset the index, list or the rewindUnits data (except at the start of the level).

    3. when you rewind.. just make sure you don't loop back any further than the max buffer size (rather than checking for index 0 as it does now)
    For example.... say rewinding index say starts from index X, rewinds to 0, loops round to bufferSize-1 then continues rewinding back down to index 35 then must stop here as the full buffer has been rewound.

    This works great, it solves #1, and is much faster. enjoy :)
    Voodoo pm me if you want more info or source code changes. I'm still fiddling with some stuff.
     
    Last edited: Jul 17, 2014
  31. coolbird22

    coolbird22

    Joined:
    Mar 20, 2014
    Posts:
    38
    Is there a way to replay the recording after it has been rewound ?
     
  32. coolbird22

    coolbird22

    Joined:
    Mar 20, 2014
    Posts:
    38
    * Bump *
     
  33. Leandro95

    Leandro95

    Joined:
    Mar 18, 2015
    Posts:
    16