Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug / Crash  Bug/Crash when setting timescale to 0 in lateupdate
#1
"Using Unity 2017.3.0p1
Latest version of Unity
Coding with Bolt"

Hey, I just bought Obi Rope and Obi Cloth, the assets are amazing and i'm really happy with it, but I got my editor crash when pausing my game (I mean, my own game pause, with a menu and everything, where in my code I set timescale to 0)

I made some tests on obi because I was not having the issue before importing it. And I noticed an issue, here is a repro : 

Open let's say the benchmark scene. Put playmode. Go to time settings. Set timescale to 0. All the flags will stop (here, it's working)

Now, redo the same but this time put the obi solver to LateUpdate. The flags won't stop and may even glitch (and in my case with my pause menu, crash)

Note that I need lateUpdate, i'm using obi cloth with a puppetmaster character ragdoll. Also, I actually don't really want to pause the cloth in the pause menu (because seing everything stop expect the character's clothing is so cool) But i would like more control over that, an option that would make obi unscaled or not. 

Thanks in advance for your time, 

Jonathan.

Edit 1: the same happens with obi rope (of course, it's the same code, but I just wanted to make sure)

Edit 2: a quick way to fix it is to put the solver to fixed update before pausing the game, or simply disable the solver for the pause. But as said above, there is no options that would make it unscaled or not.
Reply
#2
(02-05-2018, 03:02 PM)Corjn Wrote: "Using Unity 2017.3.0p1
Latest version of Unity
Coding with Bolt"

Hey, I just bought Obi Rope and Obi Cloth, the assets are amazing and i'm really happy with it, but I got my editor crash when pausing my game (I mean, my own game pause, with a menu and everything, where in my code I set timescale to 0)

I made some tests on obi because I was not having the issue before importing it. And I noticed an issue, here is a repro : 

Open let's say the benchmark scene. Put playmode. Go to time settings. Set timescale to 0. All the flags will stop (here, it's working)

Now, redo the same but this time put the obi solver to LateUpdate. The flags won't stop and may even glitch (and in my case with my pause menu, crash)

Note that I need lateUpdate, i'm using obi cloth with a puppetmaster character ragdoll. Also, I actually don't really want to pause the cloth in the pause menu (because seing everything stop expect the character's clothing is so cool) But i would like more control over that, an option that would make obi unscaled or not. 

Thanks in advance for your time, 

Jonathan.

Edit 1: the same happens with obi rope (of course, it's the same code, but I just wanted to make sure)

Edit 2: a quick way to fix it is to put the solver to fixed update before pausing the game, or simply disable the solver for the pause. But as said above, there is no options that would make it unscaled or not.

Thanks for the bug report! Will fix it asap, and post a patch here.
Reply
#3
Hi there,

Here's the fix. Replace ObiSolver.cs' LateUpdate method with this one:

Code:
private void LateUpdate(){

        float lateUpdateDelta = 0;

        if (Application.isPlaying && simulationOrder == SimulationOrder.LateUpdate){

             if (Time.deltaTime > 0){

                 // smooth out timestep and accumulate it:
                 lateUpdateDelta = smoothDelta = Mathf.Lerp(Time.deltaTime,smoothDelta,0.95f);

                 AccumulateSimulationTime(lateUpdateDelta);
                 SimulateStep(lateUpdateDelta);

             }else{
                lateUpdateDelta = 0;
             }

        }

        if (!Application.isPlaying)
            return;
  
        EndFrame (simulationOrder == SimulationOrder.LateUpdate ? lateUpdateDelta : Time.fixedDeltaTime);

        if (OnFrameEnd != null)
            OnFrameEnd(this,null);
    }
Reply
#4
Thanks for the quick fix Jose Sonrisa Everything is working now !
Reply