I have a helicopter and when the rotor blades hit the wall, the should shatter. I divided them in separate pieces with a box collider and rigid body for each piece.
Right now, the just fall down when hitting the wall… But I would like it to look more realistic! I can of course add some forces, but if there is a better implementation alltogether I would like to learn about it!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotorBladeCollision : MonoBehaviour
{
Transform root;
Rigidbody rb;
private void Start()
{
root = GameObject.Find("SceneRoot").transform;
rb = gameObject.AddComponent<Rigidbody>();
GetComponent<BoxCollider>().isTrigger = true;
}
private void OnTriggerEnter(Collider collider)
{
Debug.Log($"OnTriggerEnter with {collider.gameObject.name}");
//take the rotor piece "off" and make it fall
transform.parent = root;
rb.isKinematic = false;
//remove this script as we don't need it any more
Destroy(this);
}
}