Restricting outpost access
Now that we have an inventory keeping track of the power cells that we have collected, let's set up a game mechanic that forces the player to collect all four power cells before they may be granted access to the outpost
.
We will begin by achieving this in code, then add two visual indicators for the player.
Firstly, in the form of a 2D HUD—this will be in the form of a GUITexture, the texture which will be dependent upon the charge
variable in the Inventory
script:
Secondly, in the form of a generator model that will be placed next to the outPost
object's door, the texture of which will also be swapped depending upon the value of charge
:
Restricting door access with a cell counter
In this section, we will write code into our inventory that checks that the player has enough power cells to open the door. We currently have a trigger zone in charge of opening the door, so we will amend this to query the value of charge in our new inventory, whenever the player enters the...