Controll Fire Rate in Unity!!
When you make anything related to shooting in unity, you need to controll your fire rate, and here is how you can do it.
# Get Started
Their is nothing much to tell you can just understand what is written in the code with comments.
// Variables
/////////////
private float nextFire;
[Header("Values")]
[SerializeField] private float fireRate;
// References
//////////////
private void Update()
{
// Executing the command according to fireRate;
if (Time.time >= nextFire)
{
// Your Code here
// Changing nextFire with fireRate
nextFire = Time.time + 1f / fireRate;
}
}
Comments
Thanks For Reading