Hi there
I want to have a destructible object with multiple stages.
I have 3 prefabs, first is clean, a second broken but still assembled, and a third shattered in pieces with rigidbodies.
Edit :
Prefab 1 and 2 are one GameObject with one Mesh Renderer and Box Colliders.
Only the 3rd prefab is a GameObject with multiple childs.
I have this simple script to begin with :
public class Destructible : MonoBehaviour
{
public GameObject destroyedVersion01;
void OnCollisionEnter(Collision collision)
{
if (collision.relativeVelocity.magnitude > 2)
Instantiate(destroyedVersion01, transform.position, transform.rotation);
Destroy(gameObject);
}
}
If I attach the script to prefab n°1, everything works fine, prefab n°2 is instancied.
How can I manage to have the third prefab being instancied ?
If i attach the same script to the prefab n°2, the object just disappear when collision happend.
In hope I explain myself clearly.