Search Unity

Raycasts do not register on some MeshColliders in WebGL (2017.2-.4 regression)

Discussion in 'Editor & General Support' started by AmbOcclusion, May 21, 2018.

  1. AmbOcclusion

    AmbOcclusion

    Joined:
    Sep 17, 2012
    Posts:
    33
    We are having issues with raycasts in 2017.4 on WebGL where they will not register on some objects with MeshColliders. It's not consistent and probably affects 20-40% of objects in our entire project.

    • We are using RaycastAll but RaycastNonAlloc does not fix it.
    • The MeshColliders are not convex but setting them to convex fixes some of them but causes issues with some other % of objects that didn't have problems in other scenes.
    • Some of these objects are inside of other colliders, but not all of the objects exhibiting the issue are inside of another object.
    • The issue crops up in WebGL but not in the editor. The MeshColliders return correctly 100% of the time in-editor

    The issue is reported here https://issuetracker.unity3d.com/issues/raycast-doesnt-hit-some-objects-in-webgl-build but was dismissed. I can confirm that the 2018.2 beta does not exhibit the problem but we unfortunately cannot move to a beta release for a live product.

    I cannot share a copy of the project or rip out the problem bits due to it being the company's property but I can work with someone from Unity to sort this out.
     
    robertes likes this.
  2. MoinTom

    MoinTom

    Joined:
    May 8, 2015
    Posts:
    15
    We experienced the same issue after upgrading to 2017.4.3f1. We had to downgrade to 2017.3.0p4 for our last deployment in order to "fix" it. Unfortunately i am also not able to share the source code due to it being company's property.
     
    Last edited: May 24, 2018
    robertes likes this.
  3. shaselwimmer

    shaselwimmer

    Joined:
    May 8, 2018
    Posts:
    1
    I'm experiencing this issue using the latest version of Unity on Mac (2018.1.5f1). I have a sphere that is covered in a mesh representing simple blocks. When I mouse-over with a coded RayCast in the editor, everything works fine - the blocks are detected as hit. But when I then transfer to WebGL, huge numbers of the blocks fail to pick up the raycast. I compile to Mac desktop app and everything works fine again.

    I suspect it has something to do with the floating point handling in WebGL (see this for a related issue: https://forum.unity.com/threads/sol...ray-as-transform-size-increase-choppy.459818/).

    When I maintain my camera at 0,0,0, everything works great. But when I then rotate around an object - causing the camera position to become tiny floating point values, things go wrong.

    Really need a fix for this as it renders my application unusable in WebGL.
     
    addiadriano likes this.
  4. JimStoy

    JimStoy

    Joined:
    Oct 18, 2013
    Posts:
    2
    i'm experiencing this problem too on WebGL build. works fine for other build.
    Here, a video for exemple : https://drive.google.com/open?id=1XloMHhGmBHSnrUfX2fweGFsmOA-zsf-M

    Simple scene with raycast on a maskLayer (white plane)
    Code (CSharp):
    1.     void Update () {
    2.         RaycastHit hit;
    3.         Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);
    4.         var floorLayer = LayerMask.GetMask("testFloor");
    5.  
    6.         if (Physics.Raycast(ray, out hit, 1000f, floorLayer))
    7.         {
    8.             Cube.transform.position = hit.point;
    9.  
    10.         }
    11.         Debug.Log("distance: " + hit.distance + " |point: " + hit.point + " |name:" + hit.collider.name);
    12.     }
    I tried to truncate camera position for remove tiny float but no change
     
  5. JimStoy

    JimStoy

    Joined:
    Oct 18, 2013
    Posts:
    2
    after upgrade to unity 2018.2.2f1, problem solved !
     
  6. Nyanpas

    Nyanpas

    Joined:
    Dec 29, 2016
    Posts:
    406
    Unity 2020 doesn't work.
     
  7. UnityGISTech

    UnityGISTech

    Joined:
    May 6, 2015
    Posts:
    193
    The Same Issue, with unity 2020.3.1