Search Unity

Problem with mesh collider in WebGL build

Discussion in 'Physics' started by AlexKolosov, Jan 21, 2018.

  1. AlexKolosov

    AlexKolosov

    Joined:
    Dec 20, 2014
    Posts:
    11
    Hello community.
    I have a problem with mesh collider on my mesh (made in 3ds max).

    Editor and Standalone build:

    WebGL build:


    I experimented with the change:
    1) fixed timestep value;
    2) Build settings -> Prebake collision meshes;
    3) Added rigidbody (Is Kinematick) on the plane;
    4) Added box collider and mesh collider on same time;
    5) Change rigidbody parameters: Collision Detection, Interpolate;
    6) Project Settings -> Physics - Default contact offset;
    7) Scale the plane.

    I created bug-report and the unswer was:
    Hey,

    This seems to be due to a precision problem. I am afraid we can't fix it at the moment so I will close this bug report.
    However, as a workaround, try to reduce "Fixed Timestep" in your Project's Time Settings.
    Mentioned settings can be found here - Edit > Project Settings > Time

    Reference to the original case:
    https://issuetracker.unity3d.com/issues/webgl-rigidbody-not-colliding-with-specific-mesh-colliders

    Tested in different vesion of unity3d: 2017.3.0p1, 2017.3.0p3, 5.6.2f1

    Assets attached below
     

    Attached Files:

    MFKJ and chaosmaker like this.
  2. gorea01

    gorea01

    Joined:
    Nov 30, 2017
    Posts:
    1
    i has similar issues and in my case i was using "GameObject.CreatePrimitive" and instead i made a prefab and used "GameObject.Instantiate" and my issue was fix, maybe this will help, cheers.
     
  3. chaosmaker

    chaosmaker

    Joined:
    Jul 21, 2013
    Posts:
    29
    No words about this problem? Looks like there is a lot of people having mesh collider problems in WebGL that does work on all other platforms...
     
  4. flynam

    flynam

    Joined:
    Dec 27, 2015
    Posts:
    3
    I had the same problem. I thought the issue was related to the fact that I was building a mesh at runtime but it seems that even standard meshes have the same collider problem in WebGL builds. It’s erratic though as the rays are caught in certain areas of the screens. I can’t explain it. Anyway after a lost day, I rolled back to Unity 2017.3 and the problem is now gone.
     
  5. karsnen

    karsnen

    Joined:
    Feb 9, 2014
    Posts:
    65

    hello flynam, can you mention the exact version of Unity 2017.4 you rolled back to. I've tried with 2017.4.4.f1 and 2017.4.5f1- only to fail.
     
  6. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    973
    I have the same issue in 2018.1.1
    I have changed the Fixed Timestamp from 0,02 to 0,006 - but it did not help.

    I have just a flat chamfered square one sided mesh.
    The Mesh collider doesn't work on it in WebGL.
    When I changed it to box collider it is working, but the box collider doesn't fit my purpose, because it works on all sides, while I need one side only.
     
    Last edited: Jun 18, 2018
  7. FunToSad

    FunToSad

    Joined:
    Feb 8, 2020
    Posts:
    1
    I have issue that Physic.Raycast cannot Get The MeshCollider GameObject In 2017 when I bulid WebGl, then I Use 2018.3 to bulid it works.
     
  8. mowax74

    mowax74

    Joined:
    Mar 3, 2015
    Posts:
    97
    I have the same problem in 2019.2. The collide check seems to be unprecise on WebGL. Any solution how to improve this?
    I have a capsule collider around my ego cam, that collides with MeshColliders from the ground, the walls etc.
    On standalone plattforms everything works fine, but in webgl it slips through the walls here and there.
     
    MFKJ likes this.
  9. ba55yunky

    ba55yunky

    Joined:
    Nov 29, 2018
    Posts:
    7
    Just ran in the issue while uploading to Itchio with the Unity17.4.4, when characters get stuck on the (not convex)mesh i made in blender, first i thought it was the static batching but removed al the mixed batching on the object. Will try something like, adding force to character whenever get stuck floating...
     
  10. ba55yunky

    ba55yunky

    Joined:
    Nov 29, 2018
    Posts:
    7
    As somebody said I managed to make a workaround by reimporting the "ocean mesh" in Obj instead of fbx, but still used the fbx renderer for resolution.. Didnt try the solution with the boxcollider in the same object,
     
  11. MFKJ

    MFKJ

    Joined:
    May 13, 2015
    Posts:
    264
    I have a walk camera, sometimes it fell down from the floor (mesh collider). Not always but sometimes. Maybe due to Mesh-collider issue in unity webgl.? I am using unity 2019.4.8
     
  12. trnq1ll0

    trnq1ll0

    Joined:
    Aug 30, 2019
    Posts:
    49
    I just had the same problem (Unity 2021.3.8). In the Windows build, the colliders were executed correctly, but in the WebGL build, all the objects were flying around. Luckily I discovered the checkbox "Generate Colliders" on the model page of the FBX models, after these were all activated, the colliders also worked correctly in the WebGL build.

    Edit: Unfortunately the problem seems to be solved only locally for builds on my Windows PC. Via GameCI on an Ubuntu-latest image the error still seems to occur. :-/
     
    Last edited: Nov 11, 2022
  13. forestrf

    forestrf

    Joined:
    Aug 28, 2010
    Posts:
    231
    While it's not a workaround, the only "solution" seems to be using convex colliders.

    Idk why WebGL is unable to resolve the collisions with enough precision, as some official Unity dev said, as javascript uses doubles. This is an important problem for those using webgl, makes one of the few collider types to not work.