Shooting Holes Through Walls in Unity with ManifoldCSG.
by Vicente C.
Published |
56
Share
Johann Hotzel built a free Unity library that cuts holes into meshes while a game is running. In his demo, the collider changes too, so shots can pass through.
Johann Hotzel has wanted real-time mesh booleans in Unity for years. He points to Red Faction as the sort of destruction he had in mind: blast a wall, and the opening becomes part of the level. His open-source library, ManifoldCSG, lets you cut, combine and intersect meshes while the game is running.
Each shot has to cut the mesh left by earlier shots. If two surfaces nearly line up, small rounding errors can leave cracks or flipped triangles. Once that happens, the next cut may fail.

Johann uses Manifold, an open-source C++ library, to calculate the cuts. With valid input meshes, it produces closed results that can be cut again. Johann built a C# wrapper to pass meshes between Unity and Manifold.

To make an object cuttable, you add a CsgBody component and create a CSG Shape for the cutter. In the shooting demo, the call looks like this:
// Code shared by Johann Hotzel
body.Subtract(bullet, Matrix4x4.TRS(hit.point, rotation, Vector3.one * 0.3f));
Here, bullet is the cutter, and the matrix sets its position, rotation and size. For the wall in the demo, CsgBody updates the mesh and rebuilds the collider. With an exact MeshCollider, shots can pass through the new opening. A convex collider on a moving Rigidbody fills the hole instead.
Each cut adds triangles, so later cuts take longer. In Johann’s test on an Apple Silicon Mac, early cuts took about 0.5 ms each with an exact collider. After 100 hits, they took about 6 ms.

The library supports Unity 6 on macOS and Windows. Input meshes must be closed and have Read/Write enabled.

You can try the library and read Johann’s full notes here:

Interested in Unity tools?
Our Unity Tools, Shaders, and Math for Graphics Bundle covers procedural shapes, graphics math and custom editor tools across two practical books.
Jettelly wishes you success in your professional career! Did you find an error? No worries! Write to us at [email protected], and we'll fix it!

Subscribe to our newsletter to stay up to date with our latest offers

© 2026 Jettelly Inc. All rights reserved. Made with ❤️ in Toronto, Canada