码迷,mamicode.com
首页 > Windows程序 > 详细

C# 加特效

时间:2017-05-19 23:56:49      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:let   oid   game   obj   led   private   art   ati   update   

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# 加特效

标签:let   oid   game   obj   led   private   art   ati   update   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!