I have a bomb that is being dropped and I want it to disappear and an explosion particle effect (the one that is in the unity standard assets> particle systems) to come after it. I have it so when the bomb hits the ground it disappears, but I have researched and couldn’t find anything that relates in the way I need it.
This is my script now (nothing really) and I would prefer it to be added onto this, but if it’s not possible it’s ok.
It’s easy. You need a variable that references the prefab object you want to instantiate when the bomb explodes. In your case, this prefab would be the gameobject that holds the ParticleSystem. It’s probably a good idea to destroy the explosion object after a few seconds so you scene doesn’t get cluttered with invisible objects that are no longer needed.
public GameObject explosionPrefab;//Drag the particlesystem object here in the inspector
void OnCollisionEnter(Collision otherObj) {
GameObject explosionObject = Instantiate(explosionPrefab, otherObj.transform.position, Quaternion.identity) as GameObject;
explosionObject (explosionObject , 5f);
Destroy(otherObj.gameObject);
}
}