Unity3D 之Updatel里间隔时间调用

时间:2016-06-04 19:20:09   收藏:0   阅读:962

先上方法

//如果Fire1按钮被按下(默认为ctrl),每0.5秒实例化一发子弹

public GameObject projectile;
    public float fireRate = 0.5F;
    private float nextFire = 0.0F;
    void Update() {
        if (Input.GetButton("Fire1") && Time.time > nextFire) {
            nextFire = Time.time + fireRate;
            duck clone = Instantiate(projectile, transform.position, transform.rotation);
        }
    }

 

原文:http://www.cnblogs.com/sunxun/p/5559273.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!