Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Chronos – Time Control – Unity Awards Winner

Discussion in 'Assets and Asset Store' started by LazloBonin, Apr 9, 2015.

  1. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    You definitely know how to make your stuff look nice, I always suck at that lol. Congrats!

    I think you might have a typo:
    Code (csharp):
    1.  
    2.       if (animator == null)
    3.        {
    4.          throw new ChronosException("Missing navigator for navigator recorder.");
    5.        }
    6.  
    Almost certain you mean animator and not 'navigator'

    It really sucks we don't have enough control from code over Animator to do rewinding properly. You wrote it might be buggy till 5.1, what and how exactly is it buggy?

    Another thing: it would be nice if you wrote your comments in a multi-line fashion, so I can read it in one go and don't have to scroll all the way to the end of the screen.

    Lastly, there's no sample scene? It would definitely be nice to have something setup out of the box for users to mess with. No way you could include that city in the video?

    [Edit] just found the tutorial, http://ludiq.io/chronos/tutorial - but again, I think a sample scene would be in order.

    Nerdy cheers!
     
    Last edited: May 6, 2015
  2. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    809
    D'oh! You're right about that typo. I'll have it fixed in the next version.

    What will be buggy is inter-state transitions. It's actually an interesting Unity bug: if you have a negative playback speed and attempt to change state, you'll see in the animator window that the transition line goes in the wrong direction, off the screen! It's hard to say exactly why that is, but with Animator State Parameters in Unity 5.1, I'll change the system so that this doesn't happen.

    For XML-documentation comments, they're meant to be interpreted by the IDE (MonoDevelop / Visual Studio) and show up inline as code completion hints, not be read straight from the source. But you can always turn on soft wrap in your IDE so you don't have to scroll. They all 1-liners because they're pasted from the online documentation, and I don't have time to maintain the formatting twice for every change I make.

    As I said earlier, I wrote a tutorial to teach users how to implement Chronos, thinking doing was better than seeing. You're not the first one to ask for an example pre-made scene, so I'll try to add one in the next version. I can't include the little town because it uses many paid assets from the store which I'm not allowed to redistribute.
     
    vexe likes this.
  3. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    630
    +1 some 3d demos would be great inclued in the package please
     
  4. rerwandi

    rerwandi

    Joined:
    Dec 8, 2014
    Posts:
    544
    Just want to know before buying,
    What happends when the rewinding object is colliding to other objects ?

    I.E
    Block move to point A -> B -> C
    then i want to rewind this block from point C -> B -> A
    but in point B, i spawn another block while block still moving between C to B.

    both block has collider and rigidbody.
    Are they going to collide but still moving to target position ? but we cant call that rewind because its not like that before
     
  5. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    Hi,

    Great Asset! I've quickly looked at the tutorial and started making a demo scene of my own with a 3D RigidBody, a particle system and music. It's really cool to play with. I have a couple of questions:

    1) I get an exception when I start to rewind.


    2) Once the rewinding limit it reached, I'd like to time to stop moving backwards. How do I do that?
     
  6. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    809
    Objects that are rewinding are kinematic; they don't behave physically. In your example, they would move through one another.

    1) I fixed that bug in the version I'm pushing to the asset store today, but in the mean time, you can fix it yourself by replacing line 42 in PhysicsTimer3D.cs with:

    Code (CSharp):
    1. if (useGravity && !rigidbody.isKinematic && timeline.timeScale > 0)
    2) You can use the OnExhaustRewind event of the Recorder component (a PhysicsTimer is a Recorder). Example:

    Code (CSharp):
    1. void OnExhaustRewind()
    2. {
    3.     Timekeeper.instance.Clock("Root").localTimeScale = 1;
    4. }
     
  7. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    Thanks Lazlo! I'll take your suggestions.

    Congrats on a really nice asset. Everything about it is really well done.
     
    LazloBonin likes this.
  8. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    Thanks very much for the 50% discount

    I have just bought this that seems to be awesome and amazing feature to control time, and I have seen that there is a great and complete PDF, but before reading it, I want to ask one question.

    Would be possible that I can add a dial button to be shown in a game and so the player could choose when he wants to control the time inside the game whenever you want?

    And also of course modify the speed of the time gradually (making it slower) according to the dial position, gradually changing from real time until the end of the dial position that would stop the time

    And would want if possible also to have a pause button to stop the time instantly

    Please can you be so kind to tell me how would I be able to do this? (if this is possible to do)

    I do not want to have rewind or accelerate time, ONLY slow down.


    Thanks very much for any help

    I send you my best wishes and that you can sell a lot of this asset and help may people to control the time in a beautiful and great way thanks to this you have created.

    I agree too, I have just bought this that seems to be awesome and amazing feature to control time as seen in the beautiful, lovely and great video that looks so good, BUT also found the bad news that there is NO demo scene or ready made example to really see the effect ourselves on Unity.

    There is a tutorial to make the scene yourself, and although this is good, useful and very helpful, and I have seen that in the tutorial there is included a demo scene, to show the end result, but regretably this is not showing it in the same way as in the video only has 5 fixed options

    As other have requested, I would like also to have a demo scene showing the control time features in the same way as the video, and maybe much better in a simple 3D environment (maybe with some simple 3D cubes) instead of a 2D scene

    You are right in that doing the tutorial is better than seeing it, and I agree, and the video tutorial explained on how to do it is very good and interesting, BUT I think that having a demo scene is ALSO needed and interesting and helpful TOO

    Of course that you do NOT have to include the demo scene shown on the video, as you have said right it includes paid assets of the Store, and understand it, BUT you could make a simple scene showing the Chronos features in a easy way additionally to the well done tutorial

    Best regards
     
    Last edited: May 8, 2015
  9. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    809
    That's entirely possible. Simply get the position of the dial as a float from 0 to 1 (0 being stopped, 1 being normal time), and set the time scale of the root clock to that value. Example:

    Code (CSharp):
    1. Timekeeper.instance.Clock("Root").localTimeScale = dialPosition;
    To pause, you can use:

    Code (CSharp):
    1. Timekeeper.instance.Clock("Root").paused = true;
    I cannot help you with the code or 3D models of an interactible dial, though. I'm sure there are tutorials for that on the internet.

    To everyone who asked, I'm working on a demo scene for the next version, so please be a little patient!
     
    Last edited: May 8, 2015
    vexe likes this.
  10. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    630
    what did you use for the massive shatter effect in the demo video, do all the shattered pieces then have their own recorded positions for reverse and if so would they then look like they collide in reverse by using the recorded positions so why would they go through eachother if they have recorded positions even without physics colliders?
     
  11. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    809
    I used the Fracturing and Destruction plugin with a little bit of tweaks for Chronos compatibility. Each piece has its own PhysicsTimer attached that records its position while time is going forward, so that in reverse, each gets back to its place. I don't understand the rest of your question.
     
  12. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    630
    are the physics timers attached to the pieces automatically when fracture ccurs or do you have to manually attach the timers to each piece?
     
  13. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    809
    I added them manually. But it's as simple as adding standard Unity component:

    Code (CSharp):
    1. piece.AddComponent<PhysicsTimer3D>();
     
  14. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    630
    So reverse would be no good to use with EXPLODER on the asset store as this fractures in real time and not pre-fractured?
     
  15. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    809
    I don't know that plugin in particular, but if it uses rigidbodies for the pieces, even if they are created at runtime, you can add a PhysicsTimer to them and rewind them.
     
  16. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    630
    that is very good news, thanks
     
  17. rerwandi

    rerwandi

    Joined:
    Dec 8, 2014
    Posts:
    544
    Is this not compatible with iTween or i'm using it wrong way.
    I have cube with rotation animation, and move to path using iTween.
    The rotation stopped as it should be. But the movement is still moving.
     
  18. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    809
    iTween uses its own custom scripts with Time functions from Unity. You have to replace these with Chronos equivalents (see http://ludiq.io/chronos/migration).

    Do the following changes in iTween.cs and it should become compatible with Chronos.

    Search: Time.deltaTime
    Replace: GetComponent<Timeline>().deltaTime

    Search: Time.time
    Replace: GetComponent<Timeline>().time

    Search: new WaitForSeconds
    Replace: GetComponent<Timeline>().WaitForSeconds

    Add the Chronos namespace in usings:
    Code (CSharp):
    1. #region Namespaces
    2. using System;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5. using System.Reflection;
    6. using UnityEngine;
    7. using Chronos;
    8. #endregion
    Add a require component to the class: (optional, but a good reminder)
    Code (CSharp):
    1. [RequireComponent(typeof(Timeline))]
    2. public class iTween : MonoBehaviour {
    Tell me if that works!
     
    Pricelove, Gojira96 and bloogames like this.
  19. rerwandi

    rerwandi

    Joined:
    Dec 8, 2014
    Posts:
    544
    Thanks, it works!
    But now i have another issues.
    The iTween can't loop while rewind.

    And i think i got a bug where you change Timeline mode with script, the timeline global clock still apply.
     
  20. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    630
    purchased, but can you please supply a simple 3d demo scene to get people started..

    thanks
     
  21. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    809
    Hi melonhead!

    I already submitted a new version of the plugin with bug fixes and an example scene, but it needs to be approved by the Unity Asset Store team (and it's the weekend so they're not working). Hopefully, it'll be out tomorrow or the day after.
     
  22. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    Thought I'd let you know., I noticed Chronos website is a resources pacman. CPU easily goes up to 30% usage and Firefox to a gig and a half just by browsing the tutorial. Maybe something worthwhile to consider improving.
     
  23. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    Quick question: How does Chronos keep track of state? Like health, AI state etc. [Edit: could it be possible via Occurrences? or maybe a Recorder?]
     
    Last edited: May 11, 2015
  24. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    809
    Hm, odd. Probably because of the CSS3 animation for the moving background. I'll look into it.

    You could extend the recorder class (see the Recorder docs) to keep track of your state variable at regular intervals, but using Occurrences is probably leaner on the memory usage (and more precise). Extend the Occurrence class and set Forward to change to the new state, Backward to revert back to the old one.
     
    vexe likes this.
  25. c6u2

    c6u2

    Joined:
    Nov 15, 2013
    Posts:
    31
    Is there any possibility for unity 4.6?
     
    kenlem likes this.
  26. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    4.6 support would be nice.
     
  27. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    809
    Starting with Unity 5.1, Chronos will use the new animator state parameters, as they are the only way of properly rewinding animators (there is none in Unity 4.6). That's why I preemptively used the 5.0 limitation as to not lock out customers from upgrades.

    Unless you have a strict limit for upgrading, I suggest you try the project conversion wizard. So far, it has worked flawlessly for me and U5 is very stable.
     
  28. rerwandi

    rerwandi

    Joined:
    Dec 8, 2014
    Posts:
    544
    How can i rewind audio that play oneshot, like footsteps ?
     
  29. DanScallion

    DanScallion

    Joined:
    Jun 16, 2014
    Posts:
    4
    Would this allow to make game similar to Time Shift? Also would enemy after time rewinding behave the same way as last time or not? Also will it be possible to collide with it after rewinding?
     
  30. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    809
    Hm, that's an interesting question. I'm guessing you keep the same GameObject / AudioSource, but just make it play often, right? My suggestion would be to use an occurrence that does a backward-only action to set the play position in the audio source. Here's some prototype code. Tell me if it works!

    Code (CSharp):
    1. class PlaceAudioRewind : Occurrence
    2. {
    3.     AudioSource audio;
    4.    
    5.     public PlaceAudioRewind(AudioSource audio)
    6.     {
    7.         this.audio = audio;
    8.     }
    9.    
    10.     public override void Forward()
    11.     {
    12.         // Nothing to do
    13.     }
    14.    
    15.     public override void Backward()
    16.     {
    17.         // Place the cursor at the end so rewind
    18.         // can play it from the end to the beginning
    19.        
    20.         audio.time = audio.clip.length;
    21.     }
    22. }
    23.  
    24. // When you play the audio
    25. AudioSource audio = GetComponent<AudioSource>();
    26. Timeline time = GetComponent<Timeline>();
    27. audio.Play();
    28. time.Plan(false, audio.clip.length, new PlaceAudioRewind(audio));
    Yes, Chronos could power a game like Time Shift.

    Would enemies behave the same way? Yes, if your own AI code is not random. No, if your AI code is random or depends on factors that changed while rewind (e.g. the position of the player). Chronos does not play recorded snapshots forward; when time goes forward, your own code is responsible for the logic.

    Rigidbodies will collide after rewinding, but remember they're kinematic while rewinding. This means that unless the other object (e.g. the bullet) is kinematic, collisions won't occur, because Unity only handles collisions when at least one of the two objects is kinematic.
     
  31. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    It would be nice if Chronos reloaded well when Unity hot-reloads / reloads assemblies in the middle of playmode (when modifying scripts). Right now it throws errors:

    Code (csharp):
    1.  
    2. ChronosException: Unknown global clock 'Players'.
    3. Chronos.Timekeeper.Clock (System.String key) (at Assets/Package/Chronos/Timekeeper.cs:69)
    4. TimeControl.Update () (at Assets/Scripts/TimeControl.cs:9)
    5.  
    6. NullReferenceException: Object reference not set to an instance of an object
    7. Chronos.AnimatorRecorder.CopySnapshot () (at Assets/Package/Chronos/AnimatorRecorder.cs:68)
    8. Chronos.Recorder`1[Chronos.AnimatorRecorder+Snapshot].Record () (at Assets/Package/Chronos/Recorder.cs:136)
    9. Chronos.Recorder`1[Chronos.AnimatorRecorder+Snapshot].Progress () (at Assets/Package/Chronos/Recorder.cs:120)
    10. Chronos.Recorder`1[Chronos.AnimatorRecorder+Snapshot].Update () (at Assets/Package/Chronos/Recorder.cs:53)
    11.  
    It would also be nice if you added a note in your doc about delegates. They're not raw pointers, they're actually clases. So you when pass in an anonymous delegate (via lambda or 'delegate { }') you're actually allocating memory for a new delegate object. Not very GC friendly in performance sensitive areas. Instead, you create the delegate once and cache it. Just something to let users be aware of.
     
  32. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    809
    That's the first time I hear of recompiling scripts while in play mode. Could you link me to some documentation? I see no reason why that would work, or why you would want that to work (scripts don't get modified at runtime in the final version).

    I link to the .NET documentation on delegates in the Chronos documentation. But to be honest, worrying about the memory alloc of a delegate is almost always premature optimization; it'd be like telling people not to use foreach enumerations.
     
  33. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    I'm just saying it'd be nice if they knew about it so they can reason about the cost of what they're doing and understand what's going on behind the scene :)

    Modifying scripts in playmode means you can change and test things on the fly without having to stop playmode/enter again. It's a pure editor thing that improves workflow. It would work if you play nice with Unity's serialization and reconnect things properly (references etc). You can make use of the ISerialzationCallbackReceiver to serialize things important to Chronos Unity can't (maybe those dictionaries you're using?) - Also, Awake and Start don't get called after a hot reload, but OnEnable does. So maybe you could reconnect your stuff there.
     
  34. rerwandi

    rerwandi

    Joined:
    Dec 8, 2014
    Posts:
    544
    Occurance for footsteps seems working but i play the audio forward.
    Also, i finally solved chronos rewinding with iTween ping pong loop. It's little bit tricky because the way iTween move objects.
     
    Last edited: May 13, 2015
    LazloBonin likes this.
  35. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    809
    Forgot to mention it here, but v1.2 is now out, with a couple of bugfixes and an example scene!

     
    hopeful and vexe like this.
  36. McGunn

    McGunn

    Joined:
    Aug 7, 2012
    Posts:
    33
    Love the asset. However it appears that when I slow down the physics of an object, the angular velocities aren't slowed down the way that the regular velocities are. Am I doing something wrong or is this not part of Choronos?

    Edit: Using C# btw.
     
    Last edited: May 16, 2015
  37. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    809
    The angular velocities are also affected by time effects with the exact same calculation (look at PhysicsTimer.cs and Ctrl+F angularVelocity). What makes you say that there is a problem?
     
  38. rerwandi

    rerwandi

    Joined:
    Dec 8, 2014
    Posts:
    544
    Can Chronos handle or there is a trick to rewind object that already destroyed ?
    I.E bullets that destroyed when hit. Instantiate at hit point and move backward when rewinding.
     
  39. McGunn

    McGunn

    Joined:
    Aug 7, 2012
    Posts:
    33
    Edit: I sent you a PM with video footage of my issue ticking by frame by frame.
     
    Last edited: May 16, 2015
  40. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    809
    Yes! Using Occurrences. They are events that have a forward and backward action. Destroy the bullet on forward, and spawn a new one on backward. Or simply disable/enable it for performance. You can have a look at the documentation for that here: http://ludiq.io/chronos/documentation#Occurrences
     
  41. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    349
    Hello- Playmaker user that just starting using Chronos- in my test scene I'm pausing the clock for an NPC- it stops the character as it should but the mecanim transitions still play out- I tried pausing the NPC's clock and scaled its clock time but the mecanim transitions still play out-

    How do I get chronos to instantly freeze characters who are using mecanim animations w/transtions etc?

    Also how is the "Get Global Clock" action supposed to work? Whenever I use it- it only accesses the first global clock on the Timekeeper object- I try to select others via their keys but that does not work

    Thanks!
     
    Last edited: May 18, 2015
  42. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    809
    I'm on vacation at the moment, but I will look into these problems as soon as I get back (this weekend at most). Sorry for the delay!
     
  43. Avalon3D

    Avalon3D

    Joined:
    May 19, 2015
    Posts:
    25
    Hello, I have seen this and think is very good and interesting, and can change much the game, but I want to know if there is something that may limit the time control that is only for slowing time (not for rewind or to accelerate), I mean if the time control can be used for any 3D model with any kind of materials, with or without UV, and also for particles.
     
  44. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    809
    There is no limit to what can be time-controlled, no. Out of the box, there is support for animation, transform, particles, physics, and audio, but you can even extend it to support your own custom properties and events.
     
  45. Avalon3D

    Avalon3D

    Joined:
    May 19, 2015
    Posts:
    25
    Thanks very much for your answer and very good news that it supports all these things and that you can control the time as you want

    It would be really good if there could be a slider that could control the time, at 0 point it will be all paused and freezed, and then at 50 value would be real time, so between 0 and 50 would be a degree of levels of slow motion action depending of the the value ( less or more speed) and then after 50 until 70 (for example) would be accelerate time, and maybe if you wanted to have rewind, it would be below zero values. (I do not want to have rewind)

    I do not know nothing about scripting, so how could be done this?

    I have seen that there are some sliders available on the asset store

    https://www.assetstore.unity3d.com/en/#!/content/21429

    But I do not know how to mix this with you control time scripts, would be possible that I pay you for the work time and you can make it for me?

    Thanks

    Regards
     
  46. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    809
    Chronos already supports this! It's not just states (slow, paused, accelerated, etc.), it's a simple float called the "time scale" that you can adjust to any precision you want. For instance, 1 is normal, 0 is paused, 0.5 is slow and 0.25 is slower, 3 is thrice as fast, etc. It also works in the negatives for rewind.

    It's perfectly possible to link that value to a UI slider. The demo scene included in the package actually uses Unity's built-in sliders with Chronos. See here:

     
  47. super-cypher

    super-cypher

    Joined:
    May 10, 2014
    Posts:
    117
    Same here. would be cool if you could do the same example scene but with playmaker when you get back from your hols!
     
    Last edited: May 21, 2015
  48. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    349
    Thank you for the reply- looking forward to more information/examples on how to use Chronos with Playmaker correctly and information about my issue with the get global clock action- thanks
     
  49. aGreed

    aGreed

    Joined:
    May 25, 2015
    Posts:
    2
    Hi, sorry for posting a question here but I don't get a confirmation e-mail from your website to register and post there.

    I'm currently trying to build an AI which also should be rewindable and the huge problem was all AI's outthere use addForce, which bypasses your Physics2DTimer .. or what it's exact name was.

    Now I wanted to build this using Playmaker, but my Playmaker doesn't contain the Chronos actions and I can't find a way how to add them.
     
  50. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    349
    When you install Chronos- look inside the folder it adds- there is a Playmaker package- you install that to get the Playmaker actions- there's no real info available for setting it up with Playmaker though-