MD Package Technical & APi Documentation
MDM_InteractiveSurface :: MD_ModifierBase
Namespace: MDPackage.Modifiers
Deform mesh with physically based system that reacts with the outer world.
Read more here (Online documentation slide)
Public Methods
// Modify interactive surface with a specific point, size and vertice direction
public void InteractiveSurface_ModifyMesh(Vector3 worldPoint, float radius, Vector3 direction)
// Reset current surface (Reset all vertices to their initial positions)
public void InteractiveSurface_ResetSurface()
// Modify current mesh by custom RaycastEvent
public void InteractiveSurface_ModifyMesh(MDM_RaycastEvent RayEvent)
Public Fields
public bool rigidbodiesAllowed = true;

public bool customInteractionSpeed = false;
public bool continuousEffect = false;
public float interactionSpeed = 1.5f;

public bool exponentialDeformation = true;
public float radiusSoftness = 1.5f;

public Vector3 direction = new Vector3(0, -1, 0); // Not normalized
public float radius = 0.8f;
public float radiusMultiplier = 1.0f;
public bool detectRadiusSize = true;
public float minimumForceDetection = 0;

public bool restoreSurface;
public float restorationSpeed = 0.5f;

public bool collideWithSpecificObjects = false;
public string collisionTag = "";
Examples
The following paragraphs contain Interactive Surface modifier component used in a practical example - interact with the surface by the raycast at runtime.
using UnityEngine;
using MDPackage.Modifiers;

[RequireComponent(typeof(MeshFilter))]
public class SampleScript : MonoBehaviour
{
// Cache main camera in the inspector!
public Camera mainCam;

private MDM_InteractiveSurface surf;

private void Start()
 {
  // Add/Create a Interactive Surface modifier to this object right after start
  surf = MD_ModifierBase.CreateModifier<MDM_InteractiveSurface>(gameObject, MD_ModifierBase.MeshReferenceType.CreateNewReference);
  // Enable useNormalSmoothingAngle for 'smoother' looking normals
  surf.useNormalSmoothingAngle = true;
  // Add mesh collider for raycast detection
  gameObject.AddComponent<MDPackage.MD_MeshColliderRefresher>();
 }

private void Update()
 {
  // Main camera must be initialized
  if (!mainCam)
   return;

  // Additional extensions for mesh
  // If Space is pressed, subdivide mesh if possible
  if (Input.GetKeyDown(KeyCode.Space))
   surf.MDModifier_SubdivideMesh();
  // If S is pressed, smooth mesh
  if (Input.GetKeyDown(KeyCode.S))
   surf.MDModifier_SmoothMesh();
  // If R is pressed, restore mesh
  if (Input.GetKeyDown(KeyCode.R))
   surf.MDModifier_RestoreMesh();

  if (Input.GetMouseButton(0))
  {
   // Create raycast from camera to the cursor position
   Ray r = mainCam.ScreenPointToRay(Input.mousePosition);
   // Checking for a potential hit - if the hit transform is not null and equals to our surface, we can interact with the surface...
   bool hit = Physics.Raycast(r, out RaycastHit h) && h.transform && h.transform == surf.transform;
   if (hit)
    surf.InteractiveSurface_ModifyMesh(h.point, 0.5f, Vector3.down);
  }
 }
}