In WebGL build, Rigidbody only collides with Mesh Collider if it has previously collided with Box Collider

I have an issue where my collisions are ignored in the WebGL build, even though they work in the editor.

Here’s what’s happening:
Example 1: GIF by alicefromairconsole | Gfycat
Example 2: GIF by alicefromairconsole | Gfycat

The tank GameObject is a Rigidbody with Capsule Colliders.
The orange “floor” is a Mesh Collider, that white thing is a Box Collider.

If the Rigidbody ‘touches’ a Mesh Collider for the first time, it falls through, there is no collision.
If the Rigidbody first collides with a box collider however, the collision works, and after that it also collides as it should with Mesh Colliders.

In the Unity Editor, all collisions work as they should.

The issue is the same with both Convex and non-Convex Mesh Colliders.

My workaround for the moment is just to place an extra box collider for the Rigidbody to collide with “first”, but that can’t be the best solution to this. Any ideas?

Edit: I tested some more, and this also happens in an entirely empty project with just one Mesh Collider and a Rigidbody (Sphere) in it.
Even more strangely, the angle of the Mesh Collider makes a difference: As soon as the mesh collider is rotated a little, the collision works as it should.

Example 3: GIF by alicefromairconsole | Gfycat
Example 4: https://streamable.com/4y0k0
(only mesh rotation changed between these two).

In my own project, the collision also works when I rotate the “floor” mesh slightly.
Is this a bug or is there something I’m missing here?

Edit 2:
Link to build: Unity WebGL Player | New Unity Project
Link to project folder: https://drive.google.com/open?id=0B1LEzX86fi3pTnFFOHU1UTFWelk

It seems to be an issue specific to meshes made in Blender.

Edit 3:
Another test build: Unity WebGL Player | New Unity Project
Happens both with .blend files as well as blender fbx exports, but not with Wings3D, for example.

Edit 4: The issue does not happen with an obj file exported from blender, so the problem is somewhere either in the Blender export or the Unity import…

Are you certain all normals point outwards everywhere?

Added on Twitter as well: "It seems like the rigidbodies are starting off "asleep". Hitting the box collider wakes it up while the mesh collider does not. Looking into it"

Are you sure this is only affecting WebGL builds ?

I'm having exactly the same issue and my game relies entirely on one mesh collider! :( I don't know how to solve it... I tried different combinations/options. Nothing. Any idea what we can try?

mesh colliders is not stabil on webgl builds! valve fix pls! oops not valve unity fix pls!

9 Answers

9

Hi,
I took a look at your project and can repro this.

Can you be so nice to make a bug report from the linked project to also include the last scene you linked here with all the export options and the original blend file?
Thanks!

Thanks for the response. Bug report has been filed.

Update from our end:

  1. This is a precision issue that we can’t easily fix for WebGL/JS. Sorry.

  2. You can workaround this by changing the Fixed Timestep physics settings.

My workaround is placing a box collider for the rigidbody to collide with first, because then subsequent collisions with mesh colliders work. Changing the Fixed Timestep did not solve the problem for me, nor would I want to simply do ALL physics calculations more often, for performance reasons.

I cannot believe that this issue has no fix, it looks like a big issue to me. Who is not using a mesh collider for their games in webGL... I'm surprised the close the bug like that. There must be a workaround or something. Should I change the shape of my object for this? I don't want to go for that drastic measure.. Should I re-open the bug to Unity?

yup.. i figured it will be hard to read. ill update my question with proper format. thanks

Hello. I have same problem.
Standalone and Editor work, but webgl no.
Standalone build: https://youtu.be/Jbb3I8RgKw8
WebGL build: https://youtu.be/PcYLOtjYqCc

mesh colliders is not stabil on webgl builds!
valve fix pls! oops not valve unity fix pls!

@LittleLozza12 Does your player have a Collider as well? If you look at the matrix again, a static collider (aka your ladder) only fires collision with a rigidbody collider (aka a rb with a collider)

so whats happening at the end im still have this isue of mesh collider in webgl i need the mesh collider works on webgl why this is not happening ? what precision stuff man come one i have to build my game for all plataforms but since this issue now im stuck and i cant move foward now with out change all my game just for this? seriously?

Man this bug is still here?
My first WebGL build and nice surprise: HALF of my spheres go through the terrain… what the hell… please do things RIGHT or don’t do them.

Then I'm out of ideas. If you upload the project somewhere, i can take a look at it

The trick with the “Hit a Box Collider first” really works @N-Dream-AG . :slight_smile:

I must have gone through a hundred posts about this issue before I came to this post with your random researched solution of the problem.

I think I'll ask my family member who's a programmer but if that fails, where do you recommend I upload this for further help? Thanks for all your assistance.

The workaround “collide with box collider first” just saved my project. Huge thanks, @N-Dream-AG! I wonder how the root cause can be a precision problem.

I have to add: how this issue is handled or better not handled is deeply disappointing. It’s been around for 4 years?!

Happy to help. The standard repo for all code is [GitHub][1] - but if you're unfamiliar with version control it might be too much overhead. You can upload it on dropbox as well. [1]: https://github.com/

Well, I am working on the version 2022.3 and this tip also saved my build ! Really don't know if it's really a good new. :/

I spent 6 hours tyring to figure out why my boundary box wont keep my damn player on the screen. Ive also tried to make a pinball game before, ive tried networking.

LESSON LEARNED WEBGL IS BROKEN.

Yup collider’s just don’t work.

Yeah, my player also has a collider. And it's set so that it's always active, not on trigger like my ladder is.