Game Development Reference
In-Depth Information
Why?
If the inventory is visible, and the user presses I on the keyboard, we need
to do one thing (hide the buttons), but if it is not when the user presses I,
we need to do something else (show the buttons). We need Unity to keep
track of whether the inventory is or is not visible.
Step 59: Tell Unity on start that the inventory is indeed not visible:
function Start(){
inventoryPrompt = GameObject.Find("InventoryPrompt");
mainCamera = GameObject.Find("Main Camera");
fpcAegis = GameObject.Find("FPC_AegisChung");
inventoryVisible = false;
}
Step 60: Set up the scene to make sure the inventory is indeed
not visible. To do this, back in Unity, select InventoryButton_Tab
and change the Transform Position X value to -0.5 . This will slide
the buttons off the screen leaving just the InventoryPrompt visible
( Figure 16.5 ).
Figure 16.5 Sliding the buttons off the screen so just the Inventory Prompt is visible.
Step 61: Lock the cursor. Unity provides a very quick and easy way to lock
(and hide) the cursor. Make sure that when the game starts, the cursor is
indeed locked.
function Start(){
inventoryPrompt = GameObject.Find("InventoryPrompt");
mainCamera = GameObject.Find("Main Camera");
fpcAegis = GameObject.Find("FPC_AegisChung");
inventoryVisible = false;
Screen.lockCursor = true;
}
Search WWH ::




Custom Search