Search Unity

Multi physics scenes in edit mode

Discussion in 'Physics' started by FredZvt81, May 26, 2019.

  1. FredZvt81

    FredZvt81

    Joined:
    Apr 8, 2014
    Posts:
    24
    Hi!

    If I call SceneManager.CreateScene("My new scene", new CreateSceneParameters(LocalPhysicsMode.Physics2D)) in edit mode it logs an error telling me that this method can only be called in play mode and that I should use EditorSceneManager.NewScene() instead.

    But EditorSceneManager.NewScene() doesn't receives the CreateSceneParameters parameter and I can't find a way to setup the new scene with its own local physics.

    I assumed this was possible because in the documentation for PhysicsScene2D.Simulate it is stated that we can manually simulate physics in edit mode. Is that possible?

    I'm trying to create a tool to predict the physics behavior that my player will have in play mode to support the level designer.

    I'm using Unity 2018.3.14f1.
     
    Darkgaze and JuozasK like this.
  2. wheaty1995

    wheaty1995

    Joined:
    Dec 9, 2015
    Posts:
    2
    Having trouble doing a similar thing... Did you ever find a solution?
     
  3. Darkgaze

    Darkgaze

    Joined:
    Apr 3, 2017
    Posts:
    395
    Bump!
    Happening in v2019 too. So we basically can't simulate a different physics scene other than the defaultPhysicsScene in Edit Mode. We must simulate all physics.

    Has anybody managed to set the "Physics Scene" manually to a scene created with EditorSceneManager.NewScene?

    I create a scene and an object that has a rigidbody, and I want to simulate it , but only this object in this particular scene. But we can't do this... I'll have to read the code inside the CreateScene method to see what they do...
     
  4. Darkgaze

    Darkgaze

    Joined:
    Apr 3, 2017
    Posts:
    395
    I wrote a similar post in the scripting section. Seems like, at least until 2022's docs, this can't be done.
    https://forum.unity.com/threads/impossible-to-have-multiphysics-scenes-in-edit-mode.1243366/

    So this is a feature request. Allow multiphysics scenes in editor, passing a new PhysicsScene, just like with SceneManager.CreateScene... . This can be useful for simulating some objects during edit mode on a separate scene with its own PhysicsScene.Simulate() and avoid simulating the whole scene by calling Physics.Simulate()
     
  5. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,208
    So I had this same issue.

    What worked for me was to create a preview scene instead. It appears that by default it has it's own physics:

    Code (CSharp):
    1. #if UNITY_EDITOR
    2.             Scene S = EditorSceneManager.NewPreviewScene();
    3. #else
    4.             Scene S = SceneManager.CreateScene("SmooshScene", csp);
    5.             CreateSceneParameters csp = new CreateSceneParameters(LocalPhysicsMode.Physics3D);
    6. #endif