예제 #1
0
    public GameObject CreateBullet(GameObject prefab, Transform fier_point, bool isdestroy)
    {
        GameObject temp = null;

        if (BulletPool.Count > 0)
        {
            temp = BulletPool[0];
            BulletPool.Remove(temp);
            temp.SetActive(true);
        }
        else
        {
            temp = Instantiate(prefab);
        }
        temp.transform.position = fier_point.position;
        temp.transform.rotation = fier_point.rotation;

        temp.tag = SenceGameObject.PLAYER_BULLET_TAG;

        Collider_items co = temp.AddComponent <Collider_items>();

        co.recever = this;
        if (temp.GetComponent <Rigidbody>())
        {
            Rigidbody rb = temp.GetComponent <Rigidbody>();
            rb.useGravity  = false;
            rb.isKinematic = false;
            rb.AddForce(fier_point.forward * LUACH_FORCE * 2);
        }
        if (isdestroy)
        {
            //    Destroy(temp, 5f);
        }
        return(temp);
    }