Unity3D 实现爆炸效果的函数

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();
		}
	}
}


你可能感兴趣的:(Unity3D,function,button,null)