Namespace: MDPackage.Modifiers
Deform mesh with physically based system that reacts with the outer world.
Read more here (Online documentation slide)
Public Methods
public void InteractiveSurface_ModifyMesh(Vector3 worldPoint, float radius, Vector3 direction)
public void InteractiveSurface_ResetSurface()
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);
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
{
public Camera mainCam;
private MDM_InteractiveSurface surf;
private void Start()
{
surf = MD_ModifierBase.CreateModifier<MDM_InteractiveSurface>(gameObject, MD_ModifierBase.MeshReferenceType.CreateNewReference);
surf.useNormalSmoothingAngle = true;
gameObject.AddComponent<MDPackage.MD_MeshColliderRefresher>();
}
private void Update()
{
if (!mainCam)
return;
if (Input.GetKeyDown(KeyCode.Space))
surf.MDModifier_SubdivideMesh();
if (Input.GetKeyDown(KeyCode.S))
surf.MDModifier_SmoothMesh();
if (Input.GetKeyDown(KeyCode.R))
surf.MDModifier_RestoreMesh();
if (Input.GetMouseButton(0))
{
Ray r = mainCam.ScreenPointToRay(Input.mousePosition);
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);
}
}
}