Realtime Drill


Note that this feature is in experimental stage, therefore it is not stable and it can create artifacts on the newly created mesh.

MAGES gives you the ability to perform realitme drilling in meshes. In order to achieve this you will need to attach the Deformable Mesh script to the object containing the mesh and the Drill script to the tool.

Deformable Mesh

Setting up a deformable mesh

To convert a mesh into a deformable mesh, attach the “Deformable Mesh” component on the Game Object that contains its renderer.


The deformable mesh can be separated into multiple sections, based on what parts of it may be changed, as well as for optimization purposes. To separate a mesh, a list of predicates is used, which are gameobject hierarchies that contain colliders:


You can add predicates by adding to the “Predicates” property in the Deformable Mesh component:


After adding the colliders, you can convert the mesh to a deformable mesh, by clicking on the “Separate Mesh” button. This may take a few moments, based on the complexity of the mesh in question:


In this case, since we used, 2 predicates, there are a total of 3 different mesh sections:

  • The original mesh

  • And the two separated sections from the vertices that were inside the sphere colliders

In the sections list, you can check the property “Can Modify” to disable modification of the mesh section in question by all CTD scripts.

Finally, in order to be able to save the deformable mesh as a prefab select a valid path and name in the fields shown below and click Save Sections.


Then you can simply parent all the deformable mesh’s components in an empty gameobject and drag n drop it in your assets to create a reusable prefab.


The drill module enables the developer to set up a Unity GameObject as a drill tool, in order to achieve real time drilling of holes on 3D rigged and static models.

Set up

To use the Drill Module, you need to attach the Drill component onto the gameobject that we want to use as a drill. Simply click Add Component> MAGES > Mesh Deformations > Drill to add the component.


The scale of the gameObject that this script is attached to, affects the scaling of the drill area.


This gives you the following properties:

  1. Parallel Computation:

  • Option to run the code in parallel for increased performance.

  1. Local Densing:

  • Option to split every affected triangle of the drilling into four smaller ones, in order to prevent the smaller diameter holes looking like polygons.

  1. Use Interactable Item

  • Option to use this script in combination with an interactable item, such that when you have this object in your hand and then press the trigger button a drill is performed.

  1. Drill Area:

    • Option to set up the drilling axis and the radius of the drill.


      Make sure Gizmos are enabled on the Unity editor.

      • Click the edit button shown in the image below:

      • Use the handles shown in the scene to adjust the drill area to your requirements as shown below:


That last step that remains is to add a trigger collider component to the gameObject, that is aligned with the drill axis GUI that we created before:

In our example we are going to add a Box Collider.





bool parallelize

Minimize running times by executing the code in parallel.

bool localDensing

Split every affected triangle of the drilling into four smaller ones, in order to prevent the smaller diameter holes looking like polygons.

DrillAxis drillArea

Set up the drilling axis and the radius of the drill

UnityEvent OnDrillPerformed

Called whenever after this script successfully modifies a mesh section.