using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class firepoint : MonoBehaviour
{
public Transform shootpoint;
public GameObject bulletPrefab;
public float firerate = 1f;
private float nextfir;
public int ammo;
void Update()
{
if (Input.GetButtonDown("Fire1") && nextfir < Time.time)
{
Shoot();
nextfir = Time.time + firerate;
}
if (Input.GetMouseButtonDown(0) && ammo > 0)
{
reload();
}
}
void reload()
{
ammo--;
}
void Shoot()
{
Instantiate(bulletPrefab, shootpoint.position, shootpoint.rotation);
}
}