void Update() { if (!softVolume.Ready()) { return; } softVolume.Fix(); Partix.Body[] a = softVolume.GetContacts(); Vector3 v0 = softVolume.GetPosition(); foreach (Partix.Body b in a) { if (b as Partix.SoftVolume == null) { continue; } Vector3 v1 = b.GetPosition(); Vector3 diff = v1 - v0; diff.y = 0; if (diff.sqrMagnitude == 0) { continue; } Vector3 d = diff.normalized; b.AddForce(d * 320.0f); softVolume.AddForce(-d * 15.0f); // b.AddForce(Vector3.up * 10.0f); } }
void Update() { if (!softVolume.Ready()) { return; } softVolume.Fix(); Partix.Body[] a = softVolume.GetContacts(); Vector3 v0 = softVolume.GetPosition(); foreach (Partix.Body b in a) { if (b as Partix.SoftVolume == null) { continue; } b.AddForce(direction.normalized * power); } }