C#加特效

public class BulletMove:MonoBehaviour{

public float Speed=5f;

public Transform Fx;

void Start(){

Destroy(gameObject,5f);

}

void Update(){

//沿着自身z轴坐标系,移动

transform.Translate(-Vector3.forward*Speed*Time.daltaTime);

}

///刚刚接触

///<param name="other"></param>

private void OnTriggerEnter(Collider other){

//子弹和陨石发生了碰撞

var stone=other.GetComponent<Stone>();

if(stone !=null){

stone.Hit();

//销毁自身

Destroy(gameObject);

if(Fx !=null){

//生成特效

Transform fx=Instantiate(Fx);

fx.position=transform.position;

//2秒后删除自己

Destroy(fx.gameObject,2f);

}

}

}

}

posted @ 2017-06-21 15:02  维尼熊320  阅读(197)  评论(0编辑  收藏  举报