Literally merging 2 colliders together into 1.

Ok so heres my issue. I have a controllable ball with a physic material with a bounce factor of 3. I make floors out of a cube prefab thats stretched into a floor shape.

When i have to make some irregular floors, I attach 2 or more floors together which i do with vertex snapping. An example would be a square floor with a thin floor protruding out of it, thus requiring 2 different cubes, with one stretched into a square and the other stretched into a thin path which i then vertex snap to the square floor.

The PROBLEM is that both floors have their own box colliders, and if i roll from one floor to another the ball BOUNCES because it technically collided with the collider of the different floor. This is a problem because in game the 2 floors look seamless and smooth.

I have tried to solve this by merging the two cube meshes together into 1 and then generating a mesh collider for the new shape. I WAS CONVINCED THAT WOULD WORK since it’s now one single collider, but no it doesn’t. When i roll from one floor to another, the ball still bounces as if it collided with a new collider, EVEN THOUGH ITS 1 MESH WITH 1 MESH COLLIDER!!! It seems like the combine scripts reduce the draw calls and stuff but dont actually remove the “seams” between the objects to create 1 seamless collider.

I am out of ideas… do i really have to go to an external modeling program to model the complete layout of the floor and import it in? It just seems like there’s gotta be some other way to do this in the editor.

I can theoretically fiddle with the bouncy value of the physic material, such as script checking that if a collision happens and the ball collided with a floor while rolling from another floor then no bounce would occur, but it just seems so inelegant that it makes me want to screw the whole bounciness of the ball in the first place…

help? :slight_smile:

EDIT:

OK THE UNIMAGINABLE HAS HAPPENED. IF I REMOVE ALL PHYSIC MATERIALS SO THERE SHOULD BE VIRTUALLY NO BOUNCE AT ALL, THE BALL STILL BOUNCES BETWEEN FLOOR COLLIDERS, EVEN WHEN THEY ARE VERTEX SNAPPED TOGETHER SO THERE IS VIRTUALLY NO SPACE BETWEEN THEM!!! IS THIS AN INHERENT PRECISION PROBLEM IN THE ENGINE OR SOMETHING!??!?!

EDIT 2:

Ok after some testing i have come to an interesting conclusion. Combining meshes and generating a mesh collider for for the new mesh does technically get rid of the bounce problem that WOULD BE CAUSED by having 2 floor colliders next to each other. I know this because a hit sound is played whenever the ball collides with a new floor, and when i combined the floor meshes together there was no longer a hit sound played BUT THERE WAS STILL A BOUNCE!!! That makes me think that this has something to do with the geometry itself, something with 2 edges next to each other is causing the bounce to occur, EVEN IF THEY ARE VERTEX SNAPPED TOGETHER! Must be some kind of engine limitation??? or am i missing something

EDIT 3: Perhaps the problems occurs because of uneven frame rate? Maybe when the meshes are rerendered at different instances and if the ball is right between two edges, then a bounce occurs? Because it doesnt happen every single time, if i roll back and forth between different floors, sometimes it bounces sometimes not.

Is there no solution to this?? lol

using mesh colliders is a TERRIBLE idea. It will trash your framerate.

You should probably try first adding a rigidbody and then marking it iskinematic (iskinematic means it doesnt get affected by physics itself)

However you could also code up a quick script that takes 2 simple colliders and expands 1 collider to encompass the bounds of the second and then destroys the second.

Stretching a simple box collider is much better than throwing down tons of mesh colliders.