Game Development Reference
In-Depth Information
All weapons are now functional and can be controlled by the mouse. Additionally, it is pos-
sible to switch between these weapons using keyboard number keys 1, 2, and 3. The final
function we need to implement is the display of ammo count and reload progress. If you
refer to Illustration 88, you will notice a text mesh that says “(amm)” next to each weapon
name. We are going to use each one of these to display data about its weapon. If the weapon
is not currently in hand, the text “XXX” must be displayed. This method informs the player
directly which weapon he is currently holding in hand. However, if the weapon is currently
in hand, the number of remaining magazines as well as magazine size and magazine capa-
city must be displayed. For instance, we can use the format magazineSize/magazineCapacity
(x magazineCount) . Finally, if the weapon is reloading, the progress must be displayed as
percentage.
To control the display, we need to attach a script to each weapon that continuously reads
ammo data and updates the display accordingly. This script is AmmoDisplay , which is shown
in Listing 91.
Search WWH ::




Custom Search