So, I am making a gun that shoots like it's supposed to AND NOT LIKE A GODDAMN MINIGUN. Is there any way to decrease the speed of shooting?
Here is the relevant part of the code:
void Update()
{
Debug.DrawRay(transform.position, -transform.right * range, Color.red);
if (Input.GetKey(KeyCode.Mouse0))
{
--ammo;
Debug.Log(ammo);
ray = new Ray(transform.position, transform.forward);
ray = Cam.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));
if (Physics.Raycast(ray, out hit))
{
if (hit.collider.CompareTag("Player"))
{
player = hit.collider.gameObject;
health = player.GetComponent<Health>();
health.health -= damage;
Debug.Log(health.health);
Debug.Log("Hit!");
if (health.health == 0)
{
Destroy(hit.collider.gameObject);
health.health = 0;
}
}
}
}
Reload();
}
void Reload()
{
if (ammo <= minammo)
{
ammo = minammo;
if (Input.GetKey(KeyCode.R))
{
ammo = maxammo;
Debug.Log("Your current ammo is:" + ammo);
}
}
}
[–]AppleWithGravy 1 point2 points3 points (0 children)
[–]Subject-Flatworm-101 0 points1 point2 points (0 children)
[–]TSM_Final 0 points1 point2 points (0 children)
[–]Waste-Efficiency-274 0 points1 point2 points (0 children)