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.

Quick way to move all physics systems to FixedStepSimulationGroup?

Discussion in 'Physics for ECS' started by PhilSA, Sep 10, 2020.

  1. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Just a quick question: is there a ready-made util function to get or move all physics systems to the FixedStepSimulationGroup, for simulating in fixed update? Or if not, will it be moved to FixedStep by default in a future release?

    Right now I'm doing this and it works fine, but I'm just wondering what the plans are:
    Code (CSharp):
    1. void MovePhysicsSystemsToFixedTimestepGroup()
    2. {
    3.     MoveSystemToFixedStepGroup<RegisterHavok>();
    4.     MoveSystemToFixedStepGroup<BuildPhysicsWorld>();
    5.     MoveSystemToFixedStepGroup<StepPhysicsWorld>();
    6.     MoveSystemToFixedStepGroup<ExportPhysicsWorld>();
    7.     MoveSystemToFixedStepGroup<EndFramePhysicsSystem>();
    8.  
    9.     MoveSystemToFixedStepGroup<DebugStream>();
    10.     MoveSystemToFixedStepGroup<DisplayContactsSystem>();
    11.     MoveSystemToFixedStepGroup<DisplayCollisionEventsSystem>();
    12.     MoveSystemToFixedStepGroup<DisplayColliderAabbsSystem>();
    13.     MoveSystemToFixedStepGroup<DisplayBodyColliders>();
    14.     MoveSystemToFixedStepGroup<DisplayBroadphaseAabbsSystem>();
    15.     MoveSystemToFixedStepGroup<DisplayJointsSystem>();
    16.     MoveSystemToFixedStepGroup<DisplayMassPropertiesSystem>();
    17.     MoveSystemToFixedStepGroup<DisplayTriggerEventsSystem>();
    18. }
    19.  
    20. public void MoveSystemToFixedStepGroup<T>() where T : ComponentSystemBase
    21. {
    22.     FixedStepSimulationSystemGroup fixedStepGroup = World.GetOrCreateSystem<FixedStepSimulationSystemGroup>();
    23.     fixedStepGroup.AddSystemToUpdateList(World.GetOrCreateSystem<T>());
    24.     SimulationSystemGroup simulationGroup = World.GetOrCreateSystem<SimulationSystemGroup>();
    25.     simulationGroup.RemoveSystemFromUpdateList(World.GetOrCreateSystem<T>());
    26. }
    27.  
     
    Opeth001 likes this.
  2. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    Any day now, just wrapping up a release with this. :)
     
  3. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    1,029
    This is not working for me, systems are duplicated and fps highly dropped