zoukankan      html  css  js  c++  java
  • C# 加特效

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

    }                          

    }    

    }

    }

  • 相关阅读:
    BZOJ2870 最长道路
    为什么要设置Java环境变量
    JavaMail收发邮件的步骤
    Java 7开发者预览版发布
    J2EE的13种核心技术
    jdk1.5、1.6、1.7新特性详细介绍(整理)
    JAVAEE5 VS JAVAEE6
    TOCMAT的web.xml详解(转贴)
    setAttribute()和getAttribute()
    jsp servlet的区别和联系
  • 原文地址:https://www.cnblogs.com/C-9925/p/6880475.html
Copyright © 2011-2022 走看看