子弹实例化的代码

using UnityEngine;
using System.Collections;

public class fire : MonoBehaviour
{

    public float rate = 0.2f;
    public GameObject bullet;

    private void Start()
    {
        OnFire();
    }
    //实例化子弹
    public void Fire()
    {
        GameObject.Instantiate(bullet, transform.position, Quaternion.identity);
    }
    //如何实例化子弹
    public void OnFire()
    {
        InvokeRepeating("Fire",2,rate);
    }
}

 

posted @ 2016-03-31 15:43  礼桀  阅读(334)  评论(0)    收藏  举报