- Home /
Question by
TheEPICGaMeR17 · Mar 23, 2013 at 02:11 PM ·
javascriptammoreloading
reloading?
i need the script for reloading? if the script could be something like when the ammo count reaches 0, after 5 seconds in will reset to its original count.
Comment
Answer by deltamish · Mar 23, 2013 at 02:21 PM
Hi here is a very simple script
var ammoinclip:int = 0;
var ammoperclip:int = 15;
var ReloadAnim:AnimationClip;
var Weapon:Transform;
function Start(){
ammoinclip = ammoperclip;
}
function Update(){
if(ammoinclip <=0){
Reload();
}
}
function Reload(){
Weapon.animation.Play(ReloadAnim.name);
yield WaitForSeconds(Weapon.animation[ReloadAnim.name].length);///Thanks to fatfase i now know a new way to waitforseconds instead of using if(!Weapon.animation.IsPlaying(ReloadAnim.name))
ammoinclip = ammoperclip;
}
You could make it even more accurate using:
yield WaitForSeconds(Weapon.animation[ReloadAnim.name].length);
Then you won't have to spend 10 $$anonymous$$ figuring out what is the exact time to use
Your answer
Follow this Question
Related Questions
How do I add ammo and reloads? 1 Answer
musket gun script is not working 3 Answers
eating candy, spitting it out. 1 Answer
ammo display javascript 1 Answer
I Made a Revolver Script, But It's Saying There is an Error 2 Answers