Explosion at mouse

What would the script be to instantiate an Explosion prefab exactly where you click on the screen? Such as in the Detonator Package, where you click, you make an explosion.

any help on this?

well it depends... do you want a explosion to appear on the point were you click on a object?

Or, just have them in mid air at x distance away...

you would have to use raycasting...

here is a script that I wrote that creates a explosion on the point were you clicked:


var explosionPrefab : Transform;
function Update () {
    if(Input.GetKeyDown("mouse 0")){
    var ray = camera.ScreenPointToRay(Input.mousePosition);
    var hit : RaycastHit;
        var rot = Quaternion.FromToRotation(Vector3.up,hit.normal);

note: all the objects you want explosions on have to have colliders....

hope this help...