Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Feature Request PhysicsSceneExtensions.SetPhysicsScene for network simulation

Discussion in 'Physics' started by JesOb, Feb 8, 2024.

  1. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,109
    To test multi peer in single Unity Editor instance I need PhysicsSceneExtensions.SetPhysicsScene method
    so I can create new scene with its own physics world and then set that world to newly loaded scenes.
    Looks like it must be very easy to do this on C++ side.

    My goal is:
    scene_01_host - physicsWorld_01
    scene_02_host - physicsWorld_01
    scene_03_host - physicsWorld_01

    scene_01_peer - physicsWorld_02
    scene_02_peer - physicsWorld_02
    scene_03_peer - physicsWorld_02

    Is there any way to do this today?

    @MelvMay can you help with this please? :)
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,409
    Not sure how I can help but the only way to create/load a scene with its own dedicated physics "world" is to use the overloads that allow you to specify the LocalPhysicsMode.

    Changing the physics "world" everything in a scene is using is highly non-trivial and it'd be quicker to just load it that way. You could also create an empty scene with its own physics "world" then move all the root objects in the scene to it but again, that's not going to be as cheap as just loading it that way.

    https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.MoveGameObjectsToScene.html
    https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.MoveGameObjectToScene.html
     
  3. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,109
    Thanks

    Is it possible/easy, at least theoretically, to add API that receives PhysicsScene handle in LoadScene so scene will be loaded with connection to exact physics world, instead of creating new one or using default?
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,409
    It's possible yes. For now in the absence of asking for a local physics scene, it just defaults to the primary one.
     
  5. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,109
    Cool :)

    Please push this request on Unity Tasks side, it will make life on Unity GO side + networking way better :)
    It will be amazing if such feature lands into Unity 6 and if it will be backported to 2022 mmmm :)

    Please take a note here if such feature will be at least planned for some Unity version :)
    Thanks for your time :)
     
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,409
    I can mention it but I have no power to see that feature implemented nor can I promise it'll be done.

    Features are never backported in Unity, only bug fixes.
     
    JesOb likes this.