Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How do i make a reload script in unity?

I've already watched Brackeys tutorial of how to make it but on my game, it just doesn't work. If anyone can get me the script he made on that tutorial i'll be happy.

Best Answer

  • BayszBaysz Member
    Accepted Answer

      public int currentBulletCount;

      public int maxBulletCount;

      public int totalBulletCount;

      public int remainedBullet;

      void Reload()


        if (currentBulletCount != maxBulletCount)


          remainedBullet = maxBulletCount - currentBulletCount;

          currentBulletCount = maxBulletCount;

          totalBulletCount = totalBulletCount - remainedBullet;



    sorry for naming I am very bad at it 😂. The logic is for instance your gun has 17 bullets out of 30 and totally you have 90 bullets. when you reload your currentBullet must be equal to maxBulletCount which is 30. but you also keep how many bullets you are reloading . In this example it is 13 bullets you reload. Lastly , you should substract this 13 bullets from totalBullets you have which is 90 .

    Hope it is understandable and match your need


  • BayszBaysz Member

    what do you mean by reload script? Is that Invoke or InvokeRepeating that you might mean?

  • I mean that i have a gun in my game and i want to make a script that reloads it

  • BayszBaysz Member

    So after reloading you have 77 bullets left as totalBullet and your currentBullet is 30 out of 30.

  • Thanks, i really appreciate your effort to write the script and also explain. Thank you very much

  • BayszBaysz Member

    you are welcome :) keep programming and stay safe

Sign In or Register to comment.