Search Unity

Physics in Realtime? Framerate Independent

Discussion in 'Physics for ECS' started by backwheelbates, Apr 16, 2020.

  1. backwheelbates

    backwheelbates

    Joined:
    Jan 14, 2014
    Posts:
    232
    Hi,

    After noticing that some of the physics examples are playing TOO fast, I came across some threads with work arounds for forcing physics to update at Unity's fixed delta time.

    Although I'm finding that using the work around, the physics plays back too SLOW and looks like slow motion.

    I wanted to ask if there is more recent information on this? or any updates to the Physics packages that address this.

    Thanks!!

    Code (CSharp):
    1. using Unity.Entities;
    2.  
    3. public class FixedTimeStep : ComponentSystem
    4. {
    5.     private bool once = false;
    6.  
    7.     protected override void OnUpdate()
    8.     {
    9.         if (false == once)
    10.         {
    11.             FixedRateUtils.EnableFixedRateWithCatchUp(World.GetOrCreateSystem<SimulationSystemGroup>(),
    12.             UnityEngine.Time.fixedDeltaTime);
    13.             once = true;
    14.         }
    15.     }
    16. }
    17.  
     
  2. backwheelbates

    backwheelbates

    Joined:
    Jan 14, 2014
    Posts:
    232
    It might be these error messages that are slowing down the physics with EnableFixedRateWithCatchUp enabled. Im getting thousands of them, anyknow familiar with this?

    Code (CSharp):
    1. brid/Utilities/DebugDisplay/DebugStream.cs:389)
    2. Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystem.cs:108)
    3. Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystemGroup.cs:134)
    4. Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystemGroup.cs:120)
    5. Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystem.cs:108)
    6. Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ScriptBehaviourUpdateOrder.cs:200)
     
  3. backwheelbates

    backwheelbates

    Joined:
    Jan 14, 2014
    Posts:
    232