- Home /
reload gun with bullets
Im trying to make a gun reload when the reload function is called. I want the player to be able to reload whenever they want to, rather than only when the clip is empty.
So far I have
function Reload() {
if (ammoCount > 0)
{
12 - clipsize = reloadAmmount;
ammoCount - reloadAmmount;
clipsize + reloadAmmount;
BroadcastMessage ("ReloadAnimation");
}
}
The magazine has 12 shots in it, and the variable clipsize is how many bullets are in the clip. the ammoCount variable is how many bullets the player has in total, in this case, defaulted at 60. I was using reloadAmmount as a variable set to float and can change, but it doesnt seem to work. Any ideas?
Answer by Oliver Blitz · Oct 14, 2010 at 04:16 PM
You could try
ammoCount = ammoCount - reloadAmount;
clipsize = clipsize + reloadAmount;
or
ammoCount -= reloadAmount;
clipsize += reloadAmount;
if that works in Java. The two lines you have done don't assign their result, so in essence they do nothing.
Also, since reload amount is never assigned, you may want to do that. Something like 'var roloadAmount : float = 12 - clipsize;'
ahhh there we go, I was about to post a response asking about that :) thnk you very much!
Oh, skovacs1 is right of course. I totally missed that the first line was the wrong way around as well. ;)
Answer by Jeston 1 · Oct 14, 2010 at 07:47 PM
There are different types of reloading, are you reloading an entire clip at once or reloading 1 bullet at once ? The difference is that in 1 situation you set the current bullets to the clip size the other is that your just adding 1 to clip size every 'reload speed' timer hit until it hits max
Your answer
Follow this Question
Related Questions
1 script doesn't react to input 1 Answer
My machine gun code steels my clips 4 Answers
No Reload Script Works 1 Answer
Reload help 1 Answer
Reloading delay problem.. 0 Answers