- Home /
Reload ammo with Clips using variable Substraction
im thinking of a reload weapon with ammunition clips using variables, by using these vars will the concept work:
var ClipAmmo
var GunAmmo
so if R is pressed we do
GunAmmo -= 30;
ClipAmmo = 30;
the gun will shoot if ClipAmmo > 0 and when Instantiate is used i do ClipAmmo--;
will this work, if yes can anyone make up the base of script the instantiate and shoot bullet i got that already, thanks
Answer by Tarlius · Apr 01, 2013 at 06:19 AM
No, it won't work. Consider the case when there are still bullets in the gun. They will be discarded (perhaps intended?). Also, you have no check of whether the gun is full, and no checks for whether the player actually has 30 bullets. What will you do if they only have 29? Also, your model will be annoying to expand if you want to make another gun with a 60 bullet clip (for example)
On a side note, you shouldn't instantiate bullets as you shoot them, you'll get much better performance if you maintain a pool of them
Your answer
Follow this Question
Related Questions
reload script does not work when ammo is 16 2 Answers
need help deleting ammo item in inventory on gun reload 1 Answer
Reload After Magazine Is Empty 2 Answers
Reload manually in raycast? 1 Answer
reloading script problem 0 Answers