Intro
Working on a semi-realistic destruction simulation and was doing some initial testing. I 'm attempting to require a certain amount of force before an object breaks. The nature of the simulation would require multiple objects all colliding with each other.
The Problem
A cube is set to instantiate a “cut up” version of itself upon receiving a certain amount of force (mimicking weaknesses in materials. The code to achieve this is given below:
void OnCollisionEnter(Collision collision) {
if (collision.relativeVelocity.magnitude > MagnitudeThreshold) {
Object.Destroy (this.gameObject);
GameObject Fracture = (GameObject)Instantiate (Prefab, transform.position, transform.rotation);
} else {
}
On it’s own the cube breaks as expected, but when multiple “breakable” cubes are stacked and the bottom cube is removed a large “explosion” occurs - not very realistic (shown bottom image). When the “broken” prefab versions of the cubes are arranged identically they behave as expected, as shown top image.