Ammo and Health Display - Dynamic UI
Script
- Add 3 new variables
- Current Status
- Max Status
- Public Text Object
- Add in the beginning, in the Start function
- currentStatus equal to maxStatus
- Additionally, include a text object and assign the ‘currentStatus’ variable to it
AmmoText.text = currentAmmo.ToString(“Ammo: “ + currentAmmo);
- If an event occurs, update the ‘currentStatus’ by either decrementing (--) or incrementing (++) it also update the text
currentAmmo--; or currentAmmo++;
- To update the text just add this line again
AmmoText.text = currentAmmo.ToString(“Ammo: “ + currentAmmo);
- To reset, simply set ‘currentStatus’ back to ‘maxStatus’ and add the text field again
UI
- Create a new UI Text element
- UI – Legacy – Text
- Remove the text
- Relocate the text field
Combining
- Place your text object in the empty text field within you script