MeshCollider: enable can be true/false

Hello Guys,

I would need to enable/disable a mesh collider attached to a gameObject,? is there a way to do it?

Regards,
GC.

No, you can destroy it and add it again though. Depending on what you’re doing, it could work to toggle isTrigger.

–Eric

You can also put it on a child GameObject and enable/disable the child GameObject if I recall as well.

Uhm let’s say that I have a gameObject representing my cabinet with shelves… to move the cabinet, the external mesh must have a collider in order to get detected when I raycast. So, once I moved the cabinet, I want to be able to fill it with books (just more cubes). If the cube collides with the cabinet’s mesh, well I won’t put the book on the inner shelf. So, I need to temporarily disable the cabinet collider (but not the shelves collider)

Thanks,
G