MD Package Technical & APi Documentation
MDM_MeshSlime :: MD_ModifierBase
Namespace: MDPackage.Modifiers
Interactive soft 'slime' modifier with advanced settings. Contains a simple input-hookups.
Read more here (Online documentation slide)
Properties
// If enabled, the Update method will check for generic input automatically
public bool UseControls { get; set; }

public Camera MainCameraInstance { get; set; }

// Y_Only - slime will be affected only on Y axis, TowardsObjectsPivot - towards objects pivot point, CrossProduct - cross product, NormalsDirection - towards vertices normals
public DragAxisType CurrentDragAxisType { get; set; }

public bool RestoreSlime { get; set; }
public float RestorationSpeed { get; set; }

// Interaction radius in world space
public float MainRadius { get; set; }
public float MainFalloff { get; set; }
public float MainIntensity { get; set; }

public bool ReverseDrag { get; set; }
public float DragValue { get; set; }
public float DragFalloff { get; set; }
public float MaxDragSpeed { get; set; }
Public Methods
// Modify mesh on the specific world point with current mesh slime settings
public void MeshSlime_ModifyMesh(Vector3 worldPoint)
Examples
The following paragraphs contain Mesh Slime modifier used in a practical example. Hence the custom input handling.
using UnityEngine;
using MDPackage.Modifiers;

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

private MDM_MeshSlime slime;

private void Start()
 {
  // Add/Create a Mesh Slime modifier to this object right after start
  slime = gameObject.AddComponent<MDM_MeshSlime>();
  // Enable useNormalSmoothingAngle for 'smoother' looking normals
  slime.MbUseNormalSmoothingAngle = true;
  
  slime.RestoreSlime = true;
  slime.MainRadius = 0.15f;
  
  // Add mesh collider for raycast detection
  gameObject.AddComponent<MDPackage.MD_MeshColliderRefresher>();
 }

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

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

  // Mesh Slime modifier has already a built-in raycast detection, all is left is the input. Pass the input via Input-Hookups:

  slime.InputHook_CursorScreenPosition = Input.mousePosition;
  slime.InputHook_GenericButtonDown = Input.GetKey(KeyCode.Mouse0);
  
  // Or you can handle custom slime raycasting using the slime.MeshSlime_ModifyMesh(worldPoint/ raycast point);
 }
}