Mesh colliders aren't scaled properly with parent

I’m trying to scale a bunch of small parts by just scaling the parent, but somehow the mesh colliders don’t scale properly and no longer adhere to the rendered mesh. The problem doesn’t happen when rigidbodies are set to Kinematic and it disappears the moment you update any kind of scaling on the parent or objects in the editor (during play).
I’ve uploaded pictures showing before and after slight scaling change (which somehow updates the colliders to become correct).


I think I just found the root cause of the issue:
For some reason the small(child) parts are rotated slightly before being scaled, when they really shouldn’t (through some bug?), and only the visible mesh is scaled with this rotation, the mesh collider uses the un-rotated(correct) mesh.

I’ve come up with a work-around that takes the parent scaling and applies it to the children through a script, but it’s kind of a pain and really shouldn’t be an issue in the first place.

Not sure if I should make a thread about this (with a more fitting title) to get the attention of somebody working for Unity in the hope of fixing the bug.
I can provide a screenshot of the rotation bug if anybody wants one (only visible in play mode, happens on first frame, clearly visible when starting paused).

This also happens to me: I have an asteroid that breaks in a lot of pieces, the asteroid has a random scale and every piece of it has a rigidbody that rotates with the asteroid breaking, the mesh colliders only stay in mesh if the parent’s scale is equal in every axis

Non-uniform scaling is kind of a dead end a 4x4 transform hierarchy.

Basically there’s no way to rotate a non-uniform scale without keeping the entire “stack” of changes alive.

Here’s one solution:

  • pre-create a bunch of variations of your rock chunks, all different sizes, and use those (this is easiest)

OR:

  • change the mesh itself while preserving uniform scaling (ideally identity scaling) for the Transform.

If you want hints / pointers on doing this procedural generation, you’re welcome to look through my MakeGeo package, just random procgen stuff.

MakeGeo is presently hosted at these locations:

https://bitbucket.org/kurtdekker/makegeo

Whatever happens in the Unity’s matrix calculations, I think it’s natural to expect the colliders to end up with the same matrix as the mesh renderer’s. Right now this does not happen and the two end up in different matrices. Try scaling and rotating a parent, then also rotating the child. The child’s mesh collider will end up different than its corresponding mesh renderer, tested in 6000.0.23 today. (None of the cooking options fixed it. I’m going to assume it doesn’t have a solution because I don’t see any solution posted anywhere after all these years, perhaps because it’s a niche situation. Speaking of situation, I ended up changing the hierarchy to bypass the problem, and I recommend future souls reading this to think about doing the same.)

Fair enough.

In return I think it’s natural to expect that Unity probably won’t change core transform-to-child behavior in 2025.

Whatever it is, if you need a solution to a problem you’re having today, please don’t necro-post to a 7-year-old thread. If you have a new question, make a new post. It’s FREE!!

How to report your problem productively in the Unity3D forums:

http://plbm.com/?p=220

This is the bare minimum of information to report:

  • what you want
  • what you tried
  • what you expected to happen
  • what actually happened, log output, variable values, and especially any errors you see
  • links to actual Unity3D documentation you used to cross-check your work (CRITICAL!!!)

The purpose of YOU providing links is to make our job easier, while simultaneously showing us that you actually put effort into the process. If you haven’t put effort into finding the documentation, why should we bother putting effort into replying?

If you post code, only post the relevant code and always use the format button above. Do not post photographs of code.