Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

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,130
    This is not working for me, systems are duplicated and fps highly dropped