0
$\begingroup$

This is for a point and click first person adventure puzzle game. The inventory is at the bottom of the screen as you can see below.

Inventory Invisible

In this kind of game, when you click with your mouse on the box named Inventory, the actual Inventory comes up and its content become visible:

Inventory Visible

I have managed to make the inventory go up (with an animation) with the following logic bricks:

Logic Bricks

What I need to know is:

How do I trigger the second animation (Inventory goes down)?

It's like an ON and OFF switch that I need to learn how to use so please don't give me any python script (I'm learning that separately).

I need to learn how to activate a series of commands just by MOUSE OVER object and MOUSE LEFT CLICK because this entire game is based on this logic. I want to understand how logic bricks work and unfortunately the manual was of no help for me.

Thank You !

$\endgroup$
3
$\begingroup$

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:

enter image description here

enter image description here

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

enter image description here

Hint: the name of the first controller is the name of the state

State 2: hidden

enter image description here

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:

enter image description here

enter image description here

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:

enter image description here

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.

enter image description here

enter image description here

(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:

enter image description here

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.

enter image description here

You add or exchange the show/hide logic:

enter image description here

enter image description here

$\endgroup$
  • $\begingroup$ I did exactly what you did in another test just by using an overlay scene with visibility which works with mouse over only but that is not what I need because the area which is "free" when the inventory is down should be available for me to place other objects. Thanks for the effort anyway! $\endgroup$ – Miracles Happen Jan 8 '18 at 7:43
  • $\begingroup$ As mentioned just move the inventory out of the camera view (e.g. via an animation). You can use the same method to hide/view other parts of your GUI (e.g. a menu or online help). $\endgroup$ – Monster Jan 8 '18 at 21:38
0
$\begingroup$

S O L V E D ! ! !

See video demo

SCENE ONE: Camera > Sensor (Always) > Controller (And) > Actuator (Scene/Overlay Scene)

OVERLAY SCENE: Inventory > Sensor (Mouse Over, False pulse mode and TAP) Controller (And) > Actuator (Action/Inventory UP)

Inventory > Sensor (Mouse Over, True pulse mode and TAP) Controller (Nor) > Actuator (Action/Inventory Down)

That's it. Easier than I thought; I just had to get the right pulse mode when triggering the action!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.