首页 > Windows开发 > 详细

C# 加特效

时间:2017-05-19 23:25:09      阅读:316      评论:0      收藏:0      [点我收藏+]

public class BulletMove : MonoBehaviour {

public float Speed = 5f;    

public Transform Fx;

 // Use this for initialization  

void Start ()     {        

//5秒后,删除自己     

Destroy(gameObject, 5f);

 }  

 // Update is called once per frame  

void Update ()     {        

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

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

}       

/// 刚刚接触         

/// <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);                   

}                          

}    

}

}

C# 加特效

原文:http://www.cnblogs.com/C-9925/p/6880475.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!