I suggest to use messages to request showing/hiding the inventory. This way you can request both operations from any object you like just by sending an according message.
You need to message subjects:
- show inventory
- hide inventory
This can easily be implemented with a point and click logic:
Additional you can set up an equal logic listening to keyboard input. This way the player has the choice to use keyboard or mouse.
View Status
The inventory by itself should have a status that is either shown or hidden. As there are just two status you could use true/false, but I think it is better to allow more status that might come later (shown, hidden, short ...).
State Machine
I recommend to use the build in state machine.
States
You can define the states as follow:
State 1: shown
Hint: the name of the first controller is the name of the state
State 2: hidden
As the names suggest the menu should be fully shown in state "shown" and minimized/hidden in state "hidden".
The initial state can be set at the lower button bar. The upper button bar is to show the logic of the different states.
Transition
As we know what the states are good for (semantics) we can now think about when to switch to what state (transition).
state 1: shown
if receiving message "hide inventory" -> switch to state 2 "hidden"
state 2: hidden
if receiving message "show inventory" -> switch to state 1 "shown"
The implementation is straight forward:
Actions
The above logic switches from one state to another. While the logic of the state machine itself is complete with that, the audience will not see any effect. So we add some operations -> actions (not to be confused with animation actions).
There are four types of actions:
- entry actions (executed when entering a state)
- exit actions (executed when leaving a state)
- transition actions (executed when performing a specific transition)
- state actions (executed while in state)
What we wan is to play an action that moves the inventory into the camera's view, when entering show state.
Symmetric animation
When the hide animation is the reverse of the show animation we can use the flipper mode of the action actuator.
I assume frame 1 is the "hidden" pose and frame 10 is the "shown" pose:
Do not forget to enable the [Level]. It makes the sensor trigger the controller on level change.
This logic performs both the entry action (play forward) and the exit action (play reverse).
Asymmetric animation
When you have two different animations when showing and when hiding, you might want to use one entry action on state "shown" and another entry action on state "hidden". The animations can have different speeds or different curves. They should end at the same pose the other animation begins to avoid visible animation gaps.
(Hint: you can use the same always sensor by temporarily disabling "State" on the sensor column)
Toggling
Quick and dirty
You have two buttons right now. You might want to have one button for both show and hide = toggle.
As the messages are exclusive (only one will be considered while the other is ignored) you can send both of them at the same time, to get a toggle button:
Clean toggle
When you can't assume the messages are exclusive (e.g. when you have three states) you might want to introduce a "toggle inventory" message.
You add or exchange the show/hide logic: