O'Reilly logo

Unity 3.x Game Development Essentials by Will Goldstone

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

Restricting outpost access

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required