using UnityEngine; public class Crate : MonoBehaviour { public void OpenCrate() { // Detach all child items and enable their physics foreach (Transform child in transform) { child.SetParent(null); Rigidbody rb = child.GetComponent(); if (rb != null) { rb.isKinematic = false; rb.AddForce(Vector3.up * 2f + Random.insideUnitSphere, ForceMode.Impulse); } } // Optionally destroy the crate object //Destroy(gameObject); } // Example: Open crate on mouse click void UnpackCrate() { OpenCrate(); } }