Answer the question
In order to leave comments, you need to log in
Eror 1061 what to do?
using UnityEngine;
public class ExplodeCubes : MonoBehaviour {
private bool _collisionSet;
private void OnCollisionEnter(Collision collision) {
if(collision.gameObject.tag == "Cube" && !_collisionSet) {
for(int i = collision.transform.childCound - 1; i >= 0; i--) {
Transform child = collision.transform.GetChild(i);
child.gameObject.AddComponent<Rigidbody>();
child.gameObject.GetComponent<Rigidbody>().AddExplosionForce(70f, Vector3.up, 5f);
child.SetParent(null);
}
Destroy(collision.game0bject);
_collisionSet = true;
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question