Hey guys,
I was adding a muzzle flash to my gun and found a weird problem, the light itself is just a point light. First of all, im using this function to time the muzzle flash so it only lights up when I fire my gun:
function WaitForMuzzle()
{
if(muzzleTimer < 0)
{
muzzleFlash.enabled = false;
muzzleTimer = 0.5;
}
else
{
muzzleTimer = muzzleTimer - 50.0 * Time.deltaTime;
}
}
I call this function at the input of the left mouse button just like I do for my shooting function. As you can see in my if statement i set muzzleFlash back to 0.5, the thing is that when I have my inspector open the muzzleTimer variable is sometimes still in the negative which results to the muzzle flash not lighting up when shooting. How can I prevent this from happening?