Road TO Dev — How much ammo do I have?
Now that we have a working ammo and reload system we should really let our player know how much ammo they have at any given time. We can use the UI system to display this. First we need to create the UI Element for it. Don’t forget to set your anchor where you need it. Along with text color and size.
Next we can head over to the UIManager script and setup for updating the ammo. Of course first we need to create the handle.
Then we can create our method for updating the ammo.
Not too difficult given we’ve done this for player lives already. Next we go to the player script to communicate the ammo to the UIManager. Given our ammo count can change from a few different methods I am going to put this in the regular update.
Remember to attach the Ammo Text UI Element onto our UIManager and everything should be good to go and we will have a working ammo count system.
Note: If you want to have the number display before the first shot is fired I recommend putting this in the player start instead of the UIManager like we did with score this helps if we decide to change the amount of ammo. Then we won’t have to manually change it on the UIManager as well.