Tear

The tear module enables the developer to set up a Unity gameObject as scalpel / knife tool, in order to cut segments of rigged and static models in real time.

Set up

To use the Tear Module, you need to attach the Tear component onto the gameobject that you want to use as a scalpel / knife. Simply click Add Component> MAGES > Mesh Deformations > Tear to add the component.

../../../_images/tearComponent.png

This gives you the following properties:

  1. LineSegment tearSegment

    Option to set up the Tear Line Segment.

    For easy setup you can click the edit button in the inspector as seen below

    ../../../_images/tearEditorButton.png

    And use the handles shown in the scene to make the green point match the blade’s lower edge and the red point match the blade’s upper edge as shown in the picture below.

    ../../../_images/tearSegment.png

    Note

    Make sure Gizmos are enabled on the Unity editor.

  2. float tearPerformDistance

    The length of each tear when continuous tearring is performed.

    Warning

    Decreasing this length will make for smoother curves in the tear line but needs more performance.

  1. alpha:

    Option to set how much will the tear segment be opened.

    Example:

    ../../../_images/smallAlphaTear.png

    Tear with small alpha.

    ../../../_images/bigAlphaTear.png

    Tear with big alpha.

    Warning

    If the alpha is set to a huge value, then the tear can sometimes show some artifacts.

That last step that remains is to add a trigger collider component to the gameObject, that is aligned with the tear segment that we created before and as a result it’s also aligned with the blade. This will be used to check when a tear should be performed.

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

Properties

Property

Description

LineSegment tearSegment

The line segment based on which the tear will be performed.

float tearPerformDistance

The tear length of each individual tear in a continuous movement.

float alpha

Determines how wide the tear segment will appear, as in how much it will be “stretched”

UnityEvent OnTearPerformed

Called after this script successfully modifies a mesh section.