Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Mesh colliders became unpredictable in WebGL

Discussion in 'WebGL' started by tomekkie2, Jun 19, 2018.

  1. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    946
    This problem appeared somewhere in the course of 2017.x.x - 2018.x.x releases.
    In 5.x.x and in the early 2017.x.x releases mesh colliders were working as expected.

    My demo scene contains some meshes and some Unity primitives:

    https://virtualplayground.d2.pl/colliderTest/

    In Editor all these objects are responsive in the same way, i.e. are supposed to turn and stay red for 0.5 s on hoovering with mouse:


    In WebGL build - from meshes only the triangle and circle meshes are responsive, the rest of the meshes is not:

    The build was made in 2018.1.1f1

    Is there any fix for this and what Unity versions are the meshColliders supposed to be working in WebGL builds?
     
    Last edited: Jun 19, 2018
  2. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    Is this reproducible on 2018.2 ?
     
  3. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    946
    No idea.
    You mean is there a chance for the MeshColliders to work properly again in 2018.2 beta?
     
  4. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    Lots of fixes went into 2018.2 as well as a new version of emscripten so it's worth a try.
     
    tomekkie2 likes this.
  5. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    946
    Looks like you are right.
    I tested this scene in 2018.2.0b8 and it works in WebGL build from there.
    Thank you very much.
     
  6. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    946
    But looks like the versions starting from 2018.1.5 have some other changes in collision management, which make my project, which was working in 2018.1.1 and below - not working in these versions.
    Maybe it is some issue related to accuracy, because it is working only in the very centre of the scene, but I find it difficult to find the real problem.

    So what would be the highest version where I could downgrade the project to?
     
  7. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    Is this a bug or a breaking change? If it's a bug it would be great if you could submit a bug report.
     
  8. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    946
    The issue is:
    Object was instantiated at (0,0,0) with colliders etc., then translated immediately to other position.
    But the colliders were not updated that immediately as it was happening in 2018.1.1 and earlier.
    And this is the reason for my app to stop working.
    So I should now instantiate straightaway at the right position and not move it immediately afterwards to get the app back to work.
    So this looks like a bug, because you see the object in one place, but it's collider is in other place.
    I could probably make a demo scene to demonstrate it.
    This is not related specifically to WebGL, but probably to all the platforms.

    So: using:
    public static Object Instantiate(Object original, Vector3 position, Quaternion rotation, Transform parent);
    instead of this:
    public static Object Instantiate(Object original);
    and then moving and rotating

    - has brought my app back to work in 2018.1.5 and 2018.2.0
     
    Last edited: Jun 20, 2018
  9. Paradoks

    Paradoks

    Joined:
    Oct 13, 2009
    Posts:
    436
    @Marco-Trivellato
    Hello, like a lot of people i got problems with mesh collision in WebGL.
    In my case, it is with raycasting, my raycast dont hit the mesh collider.
    You ask for a bug report, but i am pretty sure the bug is related to this report :
    https://issuetracker.unity3d.com/issues/webgl-rigidbody-not-colliding-with-specific-mesh-colliders
    Wich has been closed. Could you tell us at least that you are trying to fix it ? Or even looking at it ?
    I am pretty desperate as i am using this mesh collider for the ground in my game, on wich i click to make my character move like in a RTS, but i dont work in webGL, so, no move, so, no game ...
    Give some news please.
     
  10. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    946
    My problem has gone, after I moved to 2018.2 beta.
    But I had to be careful to instantiate the colliders in the right place straightaway.
    Sometimes the colliders do not get updated, when I instantiated them in the default position, and then used a separate instruction to put it in some other position. The object got visually moved, but it's collider stayed in the old place.
     
  11. Paradoks

    Paradoks

    Joined:
    Oct 13, 2009
    Posts:
    436
    In fact, i wanted to keep using the Unity LTS version.
    But as you said, the problem don't looks to be totally gone in the 2018.2 beta.
    BTW i wonder if @Marco-Trivellato and @Schubkraft are still working on older unity versions or pushing the new ones.
     
  12. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    946
    Gone from WebGL.
    But this other strange updating problem arose, which affects other targets as well, at least persists in Editor.
    It was just difficult to trace the reason for strange behaviour and then I have found a fix.
     
  13. jobs

    jobs

    Joined:
    Jul 29, 2014
    Posts:
    6
    I find the same problem in 2017.4.31