Search Unity

Chronos – Time Control – Unity Awards Winner

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

  1. Arx

    Arx

    Joined:
    Jan 28, 2014
    Posts:
    22
    Great, thank you very much!
     
  2. Ssiroo

    Ssiroo

    Joined:
    Jun 17, 2014
    Posts:
    10
    Bump.
     
  3. ohbado

    ohbado

    Joined:
    Aug 13, 2014
    Posts:
    37
    Hi.
    The bug was found with Timeline.particleSystem.
    All particles that have already been discharged disappear suddenly when Timeline.particleSystem.Stop() is executed.
    As for this, ParticleSystem.Stop() and the result are different.
    Correct work of Stop() is a thing to stop the generation of a new particle.
    As for the work of Timeline.particleSystem.Stop(), externals are very bad.

    Isn't there good idea?
     
  4. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    I'm back from my short break and I just received a replacement PSU for my development computer!

    I'll start looking into everyone's issues on this thread, the internal forum, and all my emails. It might take a few days, but hopefully we'll get everything sorted out quickly.

    Cheers!
     
  5. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    Here is the list of all the current issues that have been reported:
    • Physics may behave unreliably (needs testing to confirm)
    • Some component timelines are null right after instantiation
    • NavMeshAgent.speed does not get reliably updated
    • Particle systems do not respect simulation space
    • Particle systems do not provide a check for alive
    • Particle systems burst sometimes fails
    • Wrapper component properties are not applied right after instantiation
    I'll start working on all of these for v.2.0.4, which should hopefully be released in the next few days.
     
    hopeful likes this.
  6. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    Hi Arx!

    I just tested this and cannot reproduce it.

    What I did is:
    1. Create a new scene
    2. Add a 2D sprite
    3. Give it a Rigidbody2D and a Timeline
    4. Give it the following test script:
    Code (CSharp):
    1. using Chronos;
    2. using Chronos;
    3. using UnityEngine;
    4.  
    5. public class ComponentTimelineTest : MonoBehaviour
    6. {
    7.    void Awake()
    8.    {
    9.      Timeline time = GetComponent<Timeline>();
    10.  
    11.      time.CacheComponents(); // Not necessary from Start
    12.  
    13.      time.rigidbody2D.AddForce(new Vector3(0, 2000, 0));
    14.    }
    15. }
    16.  
    There is no NullReferenceException.

    Could you start from this setup, then incrementally change until you reproduce your bug?

    The only scenario I see in which Rigidbody2D could be null is if you also have a Rigidbody (not 2D) attached on the GameObject. Could that be the case?

    If you instantiate manually, you will need to call CacheComponents like so:

    Code (CSharp):
    1. Transform shotInstance = Instantiate(shotPrefab, transform.position, shotRotation) as Transform;
    2. shotInstance.GetComponent<ShotAmmo>().time.CacheComponents();
    3. shotInstance.GetComponent<ShotAmmo>().time.rigidbody2D.AddForce(shotInstance.right * shotForce);
    That is because CacheComponents can only be called on Awake, and Awake isn't called right after the instantiation.
     
  7. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    I've never used hinges, but this should be possible with Occurrences and the OnJointBreak hook.

    First, we need to create a structure to hold the joint parameters. This will be used to "transfer" them back on rewind and undo the break by creating a new joint:

    Code (CSharp):
    1. struct JointParameters
    2. {
    3.     public Vector3 anchor;
    4.     public Vector3 axis;
    5.     public float breakForce;
    6.     // etc...
    7. }
    8.  
    Then, we need to call Timeline.Do to call a rewindable action:

    Code (CSharp):
    1. void OnJointBreak(float breakForce)
    2. {
    3.     Timeline timeline = GetComponent<Timeline>();
    4.  
    5.     // Do a rewindable action...
    6.     timeline.Do
    7.     (
    8.         false, // Non-repeatable (because OnJointBreak will be recalled automatically)
    9.  
    10.         delegate // Save the joint parameters on forward
    11.         {
    12.             // Save the joint's parameters before it is automatically destroyed
    13.  
    14.             // We can't directly pass the joint because it will be destroyed
    15.             // (therefore 'null') right after OnJointBreak. That's why we
    16.             // copy its parameters in a separate structure.
    17.  
    18.             HingeJoint oldJoint = GetComponent<HingeJoint>();
    19.  
    20.             JointParameters parameters = new JointParameters()
    21.             {
    22.                 anchor = oldJoint.anchor,
    23.                 axis = oldJoint.axis,
    24.                 breakForce = oldJoint.breakForce,
    25.                 // etc...
    26.             };
    27.  
    28.             return parameters;
    29.         },
    30.  
    31.         delegate(object transfer) // Create a new joint on backward
    32.         {
    33.             JointParameters parameters = (JointParameters)transfer;
    34.  
    35.             // Recreate a new joint with the same parameters
    36.             HingeJoint newJoint = gameObject.AddComponent<HingeJoint>();
    37.  
    38.             newJoint.anchor = parameters.anchor;
    39.             newJoint.axis = parameters.axis;
    40.             newJoint.breakForce = parameters.breakForce;
    41.             // etc...
    42.         }
    43.     );
    44. }
    45.  
    In v.2.0.4, I changed delegate occurrences a bit so that you don't need to do a cast anymore. You'll be able to replace lines 31-33 with simply:

    Code (CSharp):
    1.         delegate(JointParameters parameters) // Create a new joint on backward
    2.         {
     
    Last edited: Aug 11, 2015
  8. Arx

    Arx

    Joined:
    Jan 28, 2014
    Posts:
    22
    Thanks for taking the time to do a thorough test!

    I've reproduced your scenario and you are right, it works, however! The one important thing I forgot to mention (and I'm sorry for that) is that I don't use "Record Transform" option of the Timeline component.

    Please try to set Record Transform to "false" via Inspector (uncheck it) and you'll get the NullReferenceException, which is the problem I have.

    Edit: as for your question, no, I don't have Rigidbody attached to the same object that has Rigidbody2d attached to it.
     
  9. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    Ahh! That explains it, I see. I sometimes forget that some people don't want or need to rewind. I'll make some structural changes in the background so that it works for v.2.0.4. Thanks for the thorough bug report!
     
  10. codejoy

    codejoy

    Joined:
    Aug 17, 2012
    Posts:
    204
    So I bought this asset a while ago, was just about to tinker with it pulled from asset store right into a brand new 3d project and I get the namespace error. Does this asset require something more to buy? It happens in 7 files 'The type or namespace name 'HutongGames' could not be found. Are you missing a using directive or an assembly reference?'


    Sure it is an easy fix but a bug right of the gate trying to run the example in a new project I am lost as to what is wrong.
     
  11. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    You can simply delete the PlayMaker folder under Chronos (or uncheck it when importing). It only works for users who have PlayMaker too and throws the error otherwise. I'm trying to figure out a way to circumvent that, but I'm not sure there is one.
     
  12. mensch-mueller

    mensch-mueller

    Joined:
    Nov 25, 2014
    Posts:
    156
    Perhaps you can deliver the playmaker files as a .zip inside your asset o_O
    Michael
     
  13. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    When I do that, or in a separate nested .unitypackage, the Unity editor seems to lose GUID references and the PlayMaker example scene cannot load (because it refers to elements of the global package).
     
  14. LazloBonin

    LazloBonin

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

    I tested this extensively because it's a core functionality. On my machine, it works as intended.

    I did the test you suggested with 4 cubes. They are placed from left to right with the following time scales:
    • 0.25 (4x slower)
    • 0.5 (2x slower)
    • 1 (normal speed)
    • 2 (2x faster)
    At first look, everything looks OK:

    I also logged everything to the console to make sure the calculations were right:


    As you can see, the heights and times match the time scales.

    Note that there will always be a small discrepancy between the exact time scale and the result. That's because Unity's physics engine appears to be non-deterministic and simulates things like friction etc. with seemingly random values. For this reason, heights or times can be off by a few decimals (e.g. 1.72m vs 1.76m). I don't believe there is anything I can do about this.

    If you want to do the same test, here's my setup:
    • Timekeeper in the scene with default settings
    • Each Cube has:
      • Rigidbody with the default settings
      • Box collider with the default settings
      • Timeline with mode set to Local
      • Local Clock with no parent and the time scale (0.25 / 0.5 / 1 / 2)
      • PhysicsReliabilityTest script (below)
    Code (CSharp):
    1. using Chronos;
    2. using UnityEngine;
    3.  
    4. public class PhysicsReliabilityTest : MonoBehaviour
    5. {
    6.     Timeline timeline // Shortcut to access the timeline quickly
    7.     {
    8.         get { return GetComponent<Timeline>(); }
    9.     }
    10.  
    11.     bool isJumping; // Whether the cube is jumping
    12.     float jumpTime; // Time at which we press the jump key (for logging)
    13.     Vector3 lastVelocity; // Last velocity on update (to detect falling time)
    14.  
    15.     void Update()
    16.     {
    17.         // Jump on space:
    18.  
    19.         if (Input.GetKeyDown(KeyCode.Space))
    20.         {
    21.             jumpTime = timeline.unscaledTime;
    22.             timeline.rigidbody.AddForce(new Vector3(0, 5, 0), ForceMode.Impulse);
    23.             isJumping = true;
    24.         }
    25.  
    26.         // Log falling time for debugging:
    27.  
    28.         if (isJumping) // Ignore initial collision (cubes start on the ground)
    29.         {
    30.             if (lastVelocity.y > 0 && timeline.rigidbody.velocity.y < 0)
    31.             {
    32.                 Debug.LogFormat("{0} started falling at:\n{1:0.00}s @ {2:0.00}m", name, timeline.unscaledTime - jumpTime, transform.position.y);
    33.             }
    34.  
    35.             lastVelocity = timeline.rigidbody.velocity;
    36.         }
    37.     }
    38.  
    39.     void OnCollisionEnter(Collision collision)
    40.     {
    41.         // Log landing time for debugging:
    42.  
    43.         if (isJumping) // Ignore initial collision (cubes start on the ground)
    44.         {
    45.             Debug.LogWarningFormat("{0} landed at:\n{1:0.00}s", name, timeline.unscaledTime - jumpTime);
    46.             isJumping = false;
    47.         }
    48.     }
    49. }
    50.  
    Please try starting from this setup and telling me what doesn't work from there.
     
  15. frozze

    frozze

    Joined:
    Aug 13, 2015
    Posts:
    11
    I'm having some trouble doing the slowmo explosion.

    I'm using playmaker and ultimate fracturing.

    I have a cube with 80 fragments. I've attached a timeline with record enabled to every piece, and set it to global "Root".
    I also have the timekeeper.

    Now I'm calling the explosion with playmaker, using ulimates own playmaker action: see picture.
    action.png

    However the explosion happens, but you can't see it because all the fragments are stuck? I've set the fragments to despawn after 2 secs (look at the gif).
    GifCapture-201508132004143173.gif
    Is it because the force needs to be multiplied på the timescale? If so, how do I do that with playmaker?

    best regards
     
  16. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    The force needs to by multiplied by the timescale, yes. You'd have to edit the Action script for "Explode Fracturable Object", and change GetComponent<Rigidbody>().AddExplosionForce to GetComponent<Timeline>().rigidbody.AddExplosionForce. Unfortunately, I can't provide support for external plugins, but tell me how that goes.
     
  17. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Hi, I find a few bugs about TimeLine.TriggerEvents() in version2.0, and it's still there in 2.0.3.
    Another quesion, I want to create a screen space area clock, but I find AreaClock3D can't handle this case, how to fix it? The bridge may be 5 screens long and definitely I don't want make that collider too big :)
    bridge.png
    ----------------------------------------------------------------------
    BUG:
    1. Wrong order since TriggerEvents depends on lastTimeScale/timeScale
    2.png
    2. Always false
    3.png

    FIX:
    1. TimeLine.Update()
    fix2.png
    2. TimeLine.TriggerEvents()
    fix1.png
     
    Last edited: Aug 15, 2015
  18. frozze

    frozze

    Joined:
    Aug 13, 2015
    Posts:
    11
    There is no such thing as GetComponent<Rigidbody>().AddExplosionForce in the script. I tried to * the force with time.timeScale but that does nothing.

    So i went to the main script, and there was the GetComponent<Rigidbody>().AddExplosionForce.

    I then tested it with the action above, and the call method action with explode() as parameter.

    I changed it like you said (added using.chronos), but it still behaves like the gif i uploaded.

    Maybe it has something to do with the chunks being kinematic? (the cube starts static)
     
    Last edited: Aug 15, 2015
  19. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    Ah, that might be it yes. Try using:

    Code (CSharp):
    1. chunkTimeline.rigidbody.isKinematic = false;
    When I used Ultimate Fracturing and Destruction, my script was this: http://pastie.org/10302573

    The bridge should work; Chronos doesn't look for the pivot, but for collisions. Do you have a rigidbody on the bridge (even kinematic)? Unity requires at least one of two colliding objects to have a rigidbody for collisions to register.

    Thanks for spotting these event bugs! Will be fixed for v.2.0.5.
     
  20. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    I wrtie a simple script that enable/disable bridge's meshRenderer in OnStartSlowDown/OnStopSlowDown, so it's easier to debug.
    That green box(AreaClock3D) doesn't change bridge's timeline.timeScale until its right surface touch bridge's center, and it call OnStopSlowDown as soon as its left surface leave that point, the bridge is still inside though.
    I think Chronos should work as you said, just can't figure it out. Please help :)

    GIF:
    bridge.gif


    AreaClock3D:
    box.png

    Bridge: "pb_" components are ProBuilder scripts. SandRoad is my test script, pretty simple.
    sand.png
    Code (CSharp):
    1. public class SandRoad : TimeRelated {
    2.     MeshRenderer mesh;
    3.  
    4.     void Start() {
    5.         mesh = GetComponent<MeshRenderer>();
    6.     }
    7.  
    8.     public override void OnStartSlowDown()
    9.     {
    10.         mesh.enabled = true;
    11.     }
    12.  
    13.     public override void OnStopSlowDown()
    14.     {
    15.         mesh.enabled = false;
    16.     }
    17. }
    18.  
     
    Last edited: Aug 15, 2015
  21. mwozniak93

    mwozniak93

    Joined:
    Feb 4, 2015
    Posts:
    11
    Hello.
    I am trying to make a trap in 2d by using hinge joint 2d.
    I want it to has really quick movement so I check motor and set it to for example 300
    When I stop the time it doesnt affect this GAMEOBJECT with joint.
    Please fix it or tell me some walkaround

    Thanks in advance
     
  22. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    630
    @lazlo Tried the PhysicsReliabilityTest as above, the reason you are not seeing the problem is that you are only stabbing the jump key so the cubes are hardly lifting, press the key for 1 second and log the times, the longer the key is held the greater the difference in height of the cubes, this is the problem, time of force applied is giving different heights to the boxes depending on the timescale used the slower the timescale the higher the box will fly, example if force is applied for 1 second and box at 2x reaches 100 metres, box at 1x will reach say 110metres box at 0.5x will reach say 120, box at 0.25x will reach say 130metres which is not just a small difference so if force is applied for 10 seconds the heights will be even greater, i cant give an exact as for some reason the console was not reporting the times with the script it stayed blank but please try it out you may need to lower the amount of force applied in the vector3 or move the camera way back as the cubes will rise way above the screen or remove the impulse so it is not applied instantly, but these differences in height over force by time cannot be used in a game which needs a presice movement of objects.

    maybe this is a unity physics problem, but i dont get the connection between the timescale causing such a big force difference
     
    Last edited: Aug 17, 2015
  23. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    Hm, I see what you mean. The small decimal differences can become big for huge forces.

    Unfortunately, I have no idea how to fix it. I adjust the velocities and drags for rigidbodies based on a derivative of the time scale -- it seems like the only way to properly influence physics, from weeks of testing. I'm not sure which parameter I'm missing to make it perfect. Maybe that parameter isn't even exposed by the Unity API, if it exists. If you want, have a look at Chronos/Source/Timelines/RigidbodyTimeline.cs. There, you should see the code used for physics, and fiddle with it. I'll keep thinking about it, but I don't see a fix right now, sorry.

    Tested it and can confirm your bug! I'm having it fixed for v.2.0.5.

    I see, there seems to be many properties in Joint that need to be affected by Chronos. I'll look into implementing them for v.2.1, but it might take a little while.
     
  24. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    Chronos v.2.0.5 has been submitted for review!

    Changelog:
    • Smart addon-detection code for PlayMaker
    • Fixed timeline event triggers
    • Fixed unscaledDeltaTime to mimic deltaTime behaviour
    • Fixed area clocks taking transform position as a limitation
    • Added a list of limitations on the website
    For the complete changelog, see: http://ludiq.io/chronos/changelog
     
    Arx and zhuchun like this.
  25. Arx

    Arx

    Joined:
    Jan 28, 2014
    Posts:
    22
    Nice, thanks for the update! Do you have any bugtracker, github/bitbucket or anything like that?
     
  26. mwozniak93

    mwozniak93

    Joined:
    Feb 4, 2015
    Posts:
    11

    Ok, and how long would that take? I mean, If it's up to 2 months then I can do other things in my game, but if it will take more then 5 months then I will have to find a walkaround
     
  27. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    630
    @lazlo cheers, looks like a unity problem then!
     
  28. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    Na, I just use this forum thread for now. And an in-house forum too just in case: http://ludiq.io/chronos/forum/

    Should be less than 2 months.
     
  29. Arx

    Arx

    Joined:
    Jan 28, 2014
    Posts:
    22
    FYI, I registered for that forum before searching for this thread here, but when I log into it and click on "Start a discussion" or "Ask a question", I get "Permission Problem. You don't have permission to do that."

    @kunmateo1993, @ludiq : I've created a simple component which I attach (together with Timeline component) to every object with WheelJoint2D component to enable Chronos behaviour for the joint. It's not HingeJoint2D, but it might serve as a starting point. Here you are:

    Code (CSharp):
    1. using UnityEngine;
    2. using Chronos;
    3.  
    4. [DisallowMultipleComponent]
    5. public class ChronosWheelJoint2DEnabler : MonoBehaviour
    6. {
    7.     // -------------------------------------------------
    8.     // Attributes:
    9.     // -------------------------------------------------
    10.  
    11.     // -------------------- Public: --------------------
    12.  
    13.     // -------------------- Private: --------------------
    14.  
    15.     // current timescale of the Timeline component attached to this object
    16.     private float CurrentTimescale = 1f;
    17.  
    18.     // holds the reference to Timeline component on this game object
    19.     private Timeline Timeline;
    20.  
    21.     // holds the reference to Wheel Joint 2D component of this game object
    22.     private WheelJoint2D ThisWheelJoint;
    23.  
    24.     // the initial speed of the motor of the joint
    25.     private float InitialMotorSpeed;
    26.  
    27.  
    28.     // -------------------------------------------------
    29.     // Unity Callback methods:
    30.     // -------------------------------------------------
    31.     void Start()
    32.     {
    33.         Timeline = GetComponent<Timeline>();
    34.  
    35.         // get current timescale
    36.         if (null != Timeline)
    37.         {
    38.             CurrentTimescale = Timeline.time;
    39.         }
    40.  
    41.         // grab the reference to the wheel joint component
    42.         CacheWheelJoint();
    43.     }
    44.  
    45.     void Update()
    46.     {
    47.         // if we have both Timeline and WheelJoint2D components on this object, adjust the motor speed of the
    48.         // WheelJoint2D  with respect to the timescale of the Timeline
    49.         if (null != Timeline && !Mathf.Approximately(CurrentTimescale, Timeline.timeScale))
    50.         {
    51.             // if ThisWheelJoint is null, try to get it (maybe it was attached only after Start of this game
    52.             // object)
    53.             if (null == ThisWheelJoint)
    54.             {
    55.                 CacheWheelJoint();
    56.             }
    57.  
    58.             if (null != ThisWheelJoint)
    59.             {
    60.                 CurrentTimescale = Timeline.timeScale;
    61.  
    62.                 JointMotor2D tempMotor = ThisWheelJoint.motor;
    63.                 tempMotor.motorSpeed = InitialMotorSpeed * Timeline.timeScale;
    64.                 ThisWheelJoint.motor = tempMotor;
    65.             }
    66.         }
    67.     }
    68.  
    69.     // -------------------------------------------------
    70.     // Custom methods:
    71.     // -------------------------------------------------
    72.  
    73.     private void CacheWheelJoint()
    74.     {
    75.         ThisWheelJoint = GetComponent<WheelJoint2D>();
    76.  
    77.         if (null != ThisWheelJoint)
    78.         {
    79.             InitialMotorSpeed = ThisWheelJoint.motor.motorSpeed;
    80.         }
    81.     }
    82. }
    It basically scans for the change of the timescale of the Timeline component and adjusts the motor speed of the WheelJoint2D appropriately. @ludiq - if there's a better way to do this, please let me know!
     
    mwozniak93 likes this.
  30. ESCGames

    ESCGames

    Joined:
    Jul 26, 2015
    Posts:
    1
    Hi and thank you for this plugin, played around with it and so far so good. The rewind is working well but I am trying to figure out how to "replay" in forward events that already happened. Like a soccer game would replay the goal from different angles or a racing game would replay the players driving.
     
  31. frozze

    frozze

    Joined:
    Aug 13, 2015
    Posts:
    11
    I finally got your script to work. However when the explosion happens it looks weird:
    GifCapture-201508182143136106.gif

    What could be wrong?
     
  32. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    As it's been said many times, Chronos is not a replay plugin. This functionality is not included. I'm working on a Replay plugin separately, but there is no timeframe for the release as of now.

    How is that setup? Is it all timelines watching a clock thats at ]0, 1[ in time scale?
     
  33. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Hi, can you send me a download link of v2.0.5? I need to make a playable demo this week and have no idea how long will the asset store's review take. Where should I email to?

    @frozze Is that Exploder? Trying to do similar things today, I hope it will looks better :)
     
    Last edited: Aug 19, 2015
  34. frozze

    frozze

    Joined:
    Aug 13, 2015
    Posts:
    11
    I'll check when I get home from work.

    @frozze Is that Exploder? Trying to do similar things today, I hope it will looks better :)[/QUOTE]

    Nop that is ultimate fracture.
    However I did try exploder, but couldn't get it to work with chronos. I was able to assign a timeline to all fragments in the fragmentpool, but the force need to be multiplied be timescale, and I could figure that out ;) Maybe you can?
     
  35. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    In short, 3 words, it doesn't work :p
    Have no idea why rigidbody with timeline doesn't work as expect, their timeScale is correct though. Even an empty gameobject with rigidbody can work in that way.
     
  36. ohbado

    ohbado

    Joined:
    Aug 13, 2014
    Posts:
    37
    I reported on the problem several weeks ago.
    I am very very embarrassed about the limitation of the particle.
    http://ludiq.io/chronos/limitations
    Does having announced the limitation list mean the problem is not repaired in the future?I despair.
    The way things are going, the particle effect for which the effect designer hopes cannot be made.

    If the 3 problem of the particles is not improved, I cannot use Chronos.
    Is the solution of these problems hopeless?
    - World simulation space cannot be used.
    - All particles shortly disappear when Stop() is executed.(It is different from ParticleSystem.Stop().)
    - IsAlive() result is every True.
     
  37. frozze

    frozze

    Joined:
    Aug 13, 2015
    Posts:
    11
    My timekeeper looks like this:
    timekeeper.PNG

    Then I used an modified version of your missle, and used playmaker to call slowExplode:

    Code (CSharp):
    1. public void slowExplode(Vector3 contact, float range, float force)
    2.     {
    3.         // vector
    4.         contact = contact;
    5.      
    6.         // radius
    7.         range = range;
    8.      
    9.         // apply an explosion force
    10.         force = force;
    11.      
    12.         // Find the physical objects in range
    13.         Collider[] nearby = Physics.OverlapSphere(contact, range);
    14.      
    15.         // Loop through them to find which one are FracturedChunks in FracturedObjects (fragments of the whole in the plugin)
    16.         HashSet<FracturedObject> fracturedObjects = new HashSet<FracturedObject>();
    17.         foreach (Collider collider in nearby)
    18.         {
    19.             FracturedChunk chunk = collider.GetComponent<FracturedChunk>();
    20.          
    21.             if (chunk != null)
    22.             {
    23.                 fracturedObjects.Add(chunk.GetComponentInParent<FracturedObject>());
    24.             }
    25.         }
    26.      
    27.         // Loop through the FracturedObjects
    28.         foreach (FracturedObject fracturedObject in fracturedObjects)
    29.         {
    30.             // Make sure it hasn't already exploded
    31.             if (fracturedObject != null && fracturedObject.isActiveAndEnabled)
    32.             {
    33.                 // Loop through each chunk of the FracturedObject
    34.                 foreach (FracturedChunk chunk in fracturedObject.GetComponentsInChildren<FracturedChunk>())
    35.                 {
    36.                     // Add a Timeline (Chronos) to the chunk if it doesn't already have one
    37.                     Timeline chunkTimeline = chunk.GetComponent<Timeline>();
    38.                     if (chunkTimeline == null)
    39.                     {
    40.                         chunkTimeline = chunk.gameObject.AddComponent<Timeline>(); // Add the Timeline...
    41.                         chunkTimeline.mode = TimelineMode.Global; // ... watching the global clock...
    42.                         chunkTimeline.globalClockKey = "Root"; // ... called "Root".
    43.                         chunkTimeline.SetRecording(30,0.01f);
    44.                         chunkTimeline.recordTransform = true;
    45.                         chunkTimeline.rigidbody.isKinematic = false; // Set the object to non-kinematic, as we're going to explode it
    46.                     }
    47.                 }
    48.              
    49.                 // Explode the object (plugin method)
    50.                 // It's important to notice that we have to manually multiply by time.timeScale here
    51.                 // because the plugin's source doesn't use Chronos' PhysicsTimer methods, of course.
    52.                 fracturedObject.Explode(contact, force * Time.timeScale);
    53.             }
    54.         }
    55.     }
    I'm not sure why the fragments jumps out so quickly.
     
    s1fr likes this.
  38. mwozniak93

    mwozniak93

    Joined:
    Feb 4, 2015
    Posts:
    11
    Hi!
    I just got shocked because of what I saw.
    Chronos is said to be suitable for mobile...
    Well I wanted to make a fireplace -I lowered max particles to 20 in parent and children, also lowered emission, compresed textures and added Timeline to be able to slow down particle effect.
    Well - I could do it, but because of Timeline component game became extremely laggy and fps was 15.
    Then I removed Timeline Component and fps was back 60

    Am I doing something wrong or Timeline on particle on mobile devices just cant work well?
     
    Last edited: Aug 21, 2015
  39. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    Chronos v.2.0.5 is out!
    http://ludiq.io/chronos/changelog


    For everyone seeing the limitations of particles: I know. I've categorized them and made them obvious on the website to be fully transparent with the users. Truth is, Unity particles are not meant to be rewound. They are not built that way, and any negative simulation fails. I had to resort to the only system I found, after days if not weeks of fiddling, to make it work: resimulation at each frame. And this comes with some drawbacks. I will try to fix Stop() and isAlive(), because I think there is a potential hack that could work. I can't figure a way to fix collisions or world space or even performance: not because I don't want to, but because I don't think it's possible. If you have any idea better than mine, please suggest it. Or try making edits yourself in Chronos/Source/Timelines/ParticleSystemTimeline.cs.
     
  40. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    I don't know, this seems OK... It's exactly how I have it setup for the video. Your values are a bit extreme (0.01 timescale and 0.01 recording interval); if you put it at more "reasonable" rates, does it work? (ex. 0.5 timescale and 0.2 recording interval). Not that Chronos is supposed to be limited for these, but maybe there's a bug there.

    Also, these lines do nothing, FYI:
    Code (CSharp):
    1.         // vector
    2.         contact = contact;
    3.    
    4.         // radius
    5.         range = range;
    6.    
    7.         // apply an explosion force
    8.         force = force;
     
  41. Async0x42

    Async0x42

    Joined:
    Mar 3, 2015
    Posts:
    104
    Hey there ludiq, since the last update I've been getting a missing parent clock error on start, however I can 100% confirm that the clock does in fact exist, I've also tried changing the prefab to other clocks.

    Code (CSharp):
    1. ChronosException: Missing parent clock: 'Root'.
    2. Chronos.Clock.Awake () (at Assets/Chronos/Source/Clock.cs:40)
    3. Chronos.LocalClock.Awake () (at Assets/Chronos/Source/LocalClock.cs:14)
    4.  
    Edit: This only occurs when I have a prefab with a Local Clock + Timeline, parented to a Global Clock. It doesn't occur on prefabs with just a Timeline set to a Global Clock, Occurs on Area Clock 2D's set to a global clock parent as well
     
    Last edited: Aug 23, 2015
  42. frozze

    frozze

    Joined:
    Aug 13, 2015
    Posts:
    11
    Setting it to a more "reasonable" recording seems to "fix" it. Or maybe it's because it's just faster and then I can't tell if it works or not.

    However if i first call the explosion, and then play around with the timescale in the globat clock, I get the effect i want. I do this by scrolling back time while in play mode, and then set it to 0.01. Take a look here:
    GifCapture-201508232001081626.gif

    It seems like a bug, or I'm not really sure why it skip some frames when i call the explosion.
     
    Last edited: Aug 23, 2015
  43. Async0x42

    Async0x42

    Joined:
    Mar 3, 2015
    Posts:
    104
    The newest version gives me errors for even the most basic global clock, so I reverted to the last released version, and I'm encountering errors when I dynamically add global clocks and assign them to gameObjects.

    Here's a basic rundown of how my code goes:

    Code (CSharp):
    1. <Initializes with>
    2.         var clock = Chronos.Timekeeper.instance.AddClock(BoundaryZoneName);
    3.         clock.parent = Chronos.Timekeeper.instance.Clock("Root");
    4.  
    5. <Assigns in different method/class>
    6.             if (mobile.GetComponent<LocalClock>() != null)
    7.                     mobile.GetComponent<LocalClock>().parent = zone.Clock;
    8.             else if (mobile.GetComponent<Timeline>() != null)
    9.                 if (mobile.GetComponent<Timeline>().mode == TimelineMode.Global)
    10.                     mobile.GetComponent<Timeline>().globalClockKey = zone.Clock.key; //zone.Clock
    11.  
    This causes Chronos to throw errors every frame saying that clock can't be found. If I change the gameObject clock while in play mode, it still causes errors. If I PAUSE the game, change the gameObject clock, then unpause, the errors go away, even though the assigned clock is exactly the same.

    This is the first time I've tried dynamically adding/changing Chronos clocks, and the way this is erroring out is really confusing, and unfortunately makes it unusable in this case.

    (PS: In the documentation, http://ludiq.io/chronos/documentation timeline.globalClock = enemiesClock;, timeline.globalClock doesn't exist with newer versions)

    Edit: I finally tracked it down to the TimeKeeper class, apparently the AddClock function adds the Component to the Timekeeper gameObject, returns the clock value, but doesn't add the new clock to the clock dictionary, which is why it was so confusing. Adding "_clocks.Add(key, clock);" to AddClock fixed my problem.

    Is this a bug? Clocks are only added to _clocks on Awake(), and AddClock seems like it should do all the work needed for you. If there's another way and I'm doing it wrong, please let me know!

    Also, this fixed that issue for me with the newest version, however I'm still getting a clock not found error on Timelines with a local clock, parented to a global clock. It seems like the clock is getting woken up because the Timekeeper Awake is called that adds all of the clock components to its list? I had to revert the changes to Clock.cs made in the latest update for it to work properly
     
    Last edited: Aug 24, 2015
  44. yurivisser

    yurivisser

    Joined:
    Dec 4, 2013
    Posts:
    3
    Hi, I'm getting and error on start while working through the tutorial.
    Code (CSharp):
    1. ChronosException: Missing parent clock: 'Main'.
    2. Chronos.Clock.Awake () (at Assets/Chronos/Source/Clock.cs:42)
    Anything I'm missing here?
     
  45. Async0x42

    Async0x42

    Joined:
    Mar 3, 2015
    Posts:
    104
    It's related to the latest version, unfortunately I had to use a backup to revert Clock.cs to the previous version. I'll PM you the fix, since Unity doesn't let you downgrade a package. Hopefully the author can submit a hotfix soon for everyone.

    Edit: Oh, the forum won't let me start a conversation with you :eek:
     
  46. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    Oh darn, didn't get forum alerts and these seem like breaking bugs.

    Hotfix #1: AddClock. Add this line after line 108 in Timekeeper.cs:
    Code (CSharp):
    1. _clocks.Add(key, clock);
    Hotfix #2: Parent clock. Move the code in Awake of Clock.cs to the beginning of Start:
    Code (CSharp):
    1.         protected virtual void Awake()
    2.         {
    3.  
    4.         }
    5.  
    6.         protected virtual void Start()
    7.         {
    8.             if (string.IsNullOrEmpty(_parentKey))
    9.             {
    10.                 parent = null;
    11.             }
    12.             else if (Timekeeper.instance.HasClock(_parentKey))
    13.             {
    14.                 parent = Timekeeper.instance.Clock(_parentKey);
    15.             }
    16.             else
    17.             {
    18.                 throw new ChronosException(string.Format("Missing parent clock: '{0}'.", _parentKey));
    19.             }
    20.  
    21.             startTime = Time.unscaledTime;
    22.  
    23.             if (parent != null)
    24.             {
    25.                 parent.Register(this);
    26.             }
    27.            
    28.             ComputeTimeScale();
    29.         }
    Please tell me if these fix your problems! If they do I'll try to push 2.0.6 tonight.
     
    Async0x42 likes this.
  47. Async0x42

    Async0x42

    Joined:
    Mar 3, 2015
    Posts:
    104
    Yep, all is OK here!
     
  48. Tony707

    Tony707

    Joined:
    Jun 15, 2015
    Posts:
    38
    Hi,

    Just encoured the same ChronosException: Missing parent clock bug.
    A simpler solution might be to put Timekeeper.cs before 0 in the script execution order.
     
  49. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    Yes, but -- correct me if I'm wrong -- execution order settings are saved on a per-project level and a plugin can't change them. I don't want users to have to go through a basic setup before using Chronos.
     
  50. Tony707

    Tony707

    Joined:
    Jun 15, 2015
    Posts:
    38
    Yes execution order settings seems to be per-project but I think each specific order is saved in each script's meta file.

    I just made a test by exporting a package with such a script and it is indeed exported and reimported with his meta data.
    Moreover I already use some others Unity plugins that comes with specific execution order settings,
    so you may be able to do the same :)

    Anyway moving the Clock code to the Start works too :)
     
    LazloBonin likes this.