Explosive like in COD 4?

Hi, in the level that I'm working on at the moment you have to plant an explosive on something ,but I don't know how to do that, does anyone???

Steps:

  1. Create you explosive model.

  2. Create your particle effect and prefab it.

  3. Delete the particle effect in the scene. :)

  4. Create a script that places an explosive. It has to provide a position and rotation, unless you are planting on the ground, then only a position.

  5. Call this function from the previously mentioned script.



var explosive : Transform;
var explosion : Renderer; //Particle Prefab goes here.

function PlaceExplosive (position : Vector3, rotation : Quaternion = Quaternion.Identity, time : float) {
     var detonator : Transform = Instantiate(explosive, position, rotation) as Transform;

     yield WaitForSeconds(time);

     Destroy(detonator.gameObject);
     Instantiate(explosion, position, rotation);
}