Skip to content

Instantly share code, notes, and snippets.

@runewake2
Created December 21, 2016 04:40
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save runewake2/2256a3d77724e3606743d7f07f734280 to your computer and use it in GitHub Desktop.
Save runewake2/2256a3d77724e3606743d7f07f734280 to your computer and use it in GitHub Desktop.
Physics based mesh deformation. This is the physics system.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PhysicsDeformer : MonoBehaviour {
public float collisionRadius = 0.1f;
public DeformableMesh deformableMesh;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnCollisionStay(Collision collision)
{
foreach (var contact in collision.contacts)
{
deformableMesh.AddDepression(contact.point, collisionRadius);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment