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?
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:
//ExplosionAtPoint.js
var explosionPrefab : Transform;
function Update () {
if(Input.GetKeyDown("mouse 0")){
var ray = camera.ScreenPointToRay(Input.mousePosition);
var hit : RaycastHit;
if(Physics.Raycast(ray,hit)){
var rot = Quaternion.FromToRotation(Vector3.up,hit.normal);
Instantiate(explosionPrefab,hit.point,rot);
}
}
}
note: all the objects you want explosions on have to have colliders....
hope this help...