|
Hi, I tried to make a fire cooler, in which my hand gun shoots, the animation work, the raycast works, then it has to cool off for 0.5 seconds in order to re-fire. So I tried the following. I created a variable that is similar to my rate of fire and called it "ShootCooler, and then set it equal to each other after the fire function. But that didn't work. Here is my code without my trials:
(comments are locked)
|
|
seems to me that's already handled in this script.. in the Fire function, with The fire function only gets entered once every .3 seconds, due to the FireRate.. If you move the lines to the end, and put all your animation, sound, etc. calls above that, It will all only be called once every .3 seconds (or whatever the rate is set to).. isn't "Rate of fire" and "cool down time" the same thing? as it stands now, the FireRate regulates both the cool down time between shots, AND the time it takes the bullet to reach its target.. so if that's what you intended, you could just add a second yield: the rate of fire works fine. I just want to add cool off to the weapon. A period of time that takes to redo the fire function and eventually the fire animation, sound, and raycast effect.
Jul 20 '12 at 04:22 AM
Radon
The fire function only gets entered once every .3 seconds, due to the FireRate.. If you move the lines yield WaitForSeconds(FireRate); CanFire = true; to the end, and put all your animation, sound, etc. calls above that, It will all only be called once every .3 seconds (or whatever the rate is set to).. isn't "Rate of fire" and "cool down time" the same thing?
Jul 20 '12 at 04:33 AM
Seth Bergman
edited my answer above, think that's what you're after..
Jul 20 '12 at 05:10 AM
Seth Bergman
Ok, so now my bullet is arriving late to my target
Jul 20 '12 at 06:22 AM
Radon
already was judging by the old code.. anyway, just delete the line yield WaitForSeconds(FireRate);.. I'll update the code above.. now instead we're using "coolDownRate", but it doesn't matter either way, it's still a float, you could just replace that with FireRate
Jul 20 '12 at 06:27 AM
Seth Bergman
(comments are locked)
|
