在unity3d中有许多的特效,使得游戏的画面感更加震撼,所以,在这我跟大家分享一下我找到的有关unity3d 爆炸特效的函数,有兴趣的同学也可以自己试一下。

[javascript] view plaincopy
var trigObj : Transform = null;
var explosion : Transform = null;
var tnt : Transform = null;
private var collidedObj : Collider[];
function Boom () {
collidedObj = Physics.OverlapSphere(tnt.transform.position, 1);
 // Physics.OverlapSphere函数能返回一组对象的集合。而这组对象便是圆内包含的对象。
// 这个圆的中心点是函数的第一个参数,第二个参数是半径大小。
for (var obj in collidedObj) {
Instantiate(explosion, obj.transform.position, transform.rotation);
 // 引用Unity3D Extention的Detonator包里的Detonator-Tiny对象,这一行能
// 实现爆炸火花的效果。
Destroy(obj.gameObject);
}
}
function Start () {
}
function Update () {
if (tnt != null) {
if (trigObj.GetComponent("Button").ReturnButtonStatus()) {
Boom();
}
}
}