I don’t know why this doesn’t work. It works for my bullet decal but not for a projectile.
using UnityEngine;
using System.Collections;
public class ChargedBulletCol : MonoBehaviour {
public GameObject DestroyParticles;
void OnCollisionEnter(Collision col) {
Debug.LogError("Collided");
DestroyParticles.SetActive (true);
Destroy (transform.parent.gameObject);
}
}
I want to destroy the clone object after it hits something.
You’re trying to destroy the parent of the object the above script is attached to. You say it works when the script is attached to a bullet decal, but not when it’s attached to a projectile.
Maybe that’s because the bullet decal has a parent object but the projectile does not?
If that’s not the case, you may want to provide some additional details…