I want my space craft to explode when it collides. Thankyou if you answer and thankyou person who answered my previose questions.
2 Answers
2var explosionEffect : Transform; // Explosion effect goes here
function OnCollisionEnter (hit : Collision)
{
if(hit.gameObject)
{
Destroy(gameObject);
Instantiate(explosionEffect, transform.position, transform.rotation);
}
}
This dose not work if you are using a characterController.
Searching UnityAnswers for "explosion" gave me a bunch of useful results, particularly one on 'Scripting Impact Explosion'.
Please search before posting new/duplicate questions.
yes but he asked for it to explode when it collides. this answer script simply deletes the collider.
– loopyllamaSimply Instantiate a particle system problem solved.
– FLASHDENMARK