Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. 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.

Question Physics simulation error

Discussion in 'Physics for ECS' started by Icon123456, Jul 19, 2023.

  1. Icon123456

    Icon123456

    Joined:
    Oct 14, 2022
    Posts:
    4
    When I'm using Unity Physics for physics simulation, I encounter the following situation. Does anyone know what's happening and how to resolve it?
    upload_2023-7-19_14-34-41.png
     

    Attached Files:

  2. Icon123456

    Icon123456

    Joined:
    Oct 14, 2022
    Posts:
    4
    The model is flat and is using a Mesh Collider.
     
  3. spinaljack

    spinaljack

    Joined:
    Mar 18, 2010
    Posts:
    992
  4. Tigrian

    Tigrian

    Joined:
    Mar 21, 2021
    Posts:
    125
    Hi!

    Here's a video explaining why this happens :



    (start at 18:54, and ends around 24:15)

    Basically, Unity physics uses a speculative continuous collision detection (which works similarly to the one in classic monobehaviour rigidbodies).

    So to solve the problem, either you need to know that the plane is completely flat and apply the solution described in the video (the rotate contact normal part, check the samples spinaljack gave you, the solution should be inside), but it won't work for things other than flat planes, OR you are a Unity pro user (and assuming you don't make a multiplayer game), you then get access to the Havok package to toggle the contact welding feature, which get rid of this effect completely, at the cost of a little performance.
     
    Last edited: Jul 25, 2023
  5. spinaljack

    spinaljack

    Joined:
    Mar 18, 2010
    Posts:
    992
    I tried the havok physics with contact welding fixes this issue

    upload_2023-7-27_12-56-17.png
     
    Tigrian likes this.
  6. daniel-holz

    daniel-holz

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    330
    While the contact welding feature in Havok addresses this problem, you can have a look at the demo "Modify /
    Narrowphase Contacts" in the PhysicsSamples project which shows how to deal with this situation also in Unity Physics.