Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Correct physics when hiding 3D model, crazy physics with 3D model present

Discussion in 'Physics' started by Jelmer123, Dec 2, 2022.

  1. Jelmer123

    Jelmer123

    Joined:
    Feb 11, 2019
    Posts:
    243
    I have a quite large 3D model in my scene, in the sense that it has many polygons.
    With the model visible, framerate is a decent 60, but somehow, the Physics system behaves completely strange. When I deactivate the gameobject, Unity Physics behave as expected.
    What on earth could this be? The 3D model is just a mesh... Can a large mesh affect the Unity Physics system??
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,321
    You provide almost zero information here.

    - Crazy: Not a specific thing.
    - Unity Physics: DOTS Physics? PhysX 3D physics?
    - Many Polygons: Polygons are 2D. You mean mesh triangle faces?

    There's a profiler which will show you exactly what is taking time. Without that, you cannot possibly reason about what the actual problem is but you are asking others which is an impossible task for anyone without information. You're posting on physics but are you sure it's not rendering issues? Why would physics have any work to do with a 3D model unless it has some kind of collider interacting with something? (you don't mention this).
     
  3. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,497
    No, unless the mesh contains colliders. Maybe the "Generate colliders" option is enabled in the mesh import settings?

    upload_2022-12-4_22-45-19.png

    If this option is disabled, then check out the hierarchy of your mesh in the scene. Surely it has some collider somewhere (Mesh Collider, Box Collider, etc).

    Another possibility is that part or all of the physics logic in your project (i.e Rigidbody.AddForce) is calculated and/or applied in Update instead of FixedUpdate in your scripts. That would make the physics highly unreliable, so variations in the frame rate (for example as result of having a big large mesh enabled) could have dramatic effects in the physics.
     
    Jelmer123 likes this.
  4. Jelmer123

    Jelmer123

    Joined:
    Feb 11, 2019
    Posts:
    243
    Thanks. I understand the info was a bit short.

    In the meantime I found out what the problem was: a box collider had forgotten its size, and had been larger than the whole scene. In other words, all physics objects in the scene where inside this collider, and thus in "colliding" mode. Which made them jump all over the place (described as "crazy" in my original post).

    About the definition of physics. I'm not aware of multiple system, and in Project Settings it is also just defined as "Physics" by unity..
     
  5. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,321
    Yes, that'd cause some problems!

    You cannot see "Physics" and "Physics 2D" in the project settings? I feel sad that you don't know about 2D physics in Unity. ;)
     
  6. Jelmer123

    Jelmer123

    Joined:
    Feb 11, 2019
    Posts:
    243
    Ah true, yeah.. VR project.. So no 2D physics for me..
     
    MelvMay likes this.