Forum rules - please read before posting.

menu/inventory question

edited October 2014 in Technical Q&A
I'm trying to get Bolt Riley's inventory work like it did in our earlier demo (done in EZGui)

see:


when you press a button in the top menu it opens up the inventory hat, from which you can perform actions or drag items outside. 
there are a few fundcionalities i can't seem to be able to reproduce in AC's inventory menu system

1. when i select an item , I want to be able to let the player interact with it (i.e. look at the item and not just pick it up to use it)
2. when i move the mouse out side (either if i selected an inventory item or not) the inventory menu should dissapear allowing me to interact with what's behind it.
like how it does it when i enable the "mouse ove" in appear type, (only that it shouldn't appear when i'm not hitting the button).

any advice on how to do it?

Oded

Comments

  • 1) You can define an "Examine" Interaction for an Inventory item in the Inventory Manager.  Just create an ActionList asset with a Dialogue: Play speech Action, and drag it over.  If you want to remove the ability to "select" the Item completely, define both an Examine and a Use Interaction - the 2D Demo does this to stop players from selecting the Worm.

    2) You can use the Menu: Change state Action to lock a Menu so that it doesn't appear, regardless of whether or not it's normal "enable rule" applies.  I'll add an "ActionList on turn off" field to 1.40 - you'll be able to use this to lock the menu once it's turned off, until you unlock it again.
  • 1) i already have an examine interacition which works on right clicking in 1.38. i'll see how it changes in 1.39 or wait for 1.40 to upgrade

    2) 
    I want to turn on the menu when i'm pressing the button. if the menu's appear type is mouseover - i get this error
    "Can only turn on menus with an Appear Type of Manual and OnInputKey."

    if it's manual, it wouldn't behave as expected , no?

    when you're impementing this take into account that if i lock and unlock the menu, i also need make it appear after unolocking it when the button is clicked. , and lock it again when my mouse goes away with that actionlist...



  • I don't understand what you're saying.  If it's Appear Type is MouseOver, then it can't be turned on / off manually, since it follows a very specific rule of visibility.  You can choose to lock it, to stop it appearing when you don't want it to, but when enabled it'll go by the Appear Type you've set it.

    If, when it's unlocked, the mouse cursor is within it's boundary, it'll appear.
  • i want to make it appear on the click of a button, that is on another menu hence the mouse cursor is not physically on the menu when you turn it on, and make it disspear when the mouse leaves the menu.

    can you see how it works in the video i posted?
  • oh, sorry for the confustion, in the video he opens the menu with an interaction. 

    this one i explain it better:
  • edited October 2014
    Since this is quite a unique behaviour, I should think this'll come down to a (very simple) custom script.  From the video, it looks like the menu should only close if you have an item selected.  Is that correct?
  • no, it also closes when you have not selctec an item.
    let me know if it's doable, if not, i need to think of some other way to do it.
  • edited October 2014
    It's do-able, but again: you still need a custom script.  If I've followed the logic here, you want the menu (once opened) to wait until the mouse has BOTH entered AND THEN exited the menu before closing.  A custom script would be able to set a bool flag to "true" once the mouse cursor is over the menu.  Something like:
    Menu myMenu = PlayerMenus.GetMenuWithName ("InventoryBag");
    PlayerInput playerInput = GameObject.FindWithTag (Tags.gameEngine).GetComponent <PlayerInput>();
    bool disableWhenMouseLeaves = false;

    void Update ()
    {
      if (myMenu.Enabled ())
      {
        if (myMenu.GetRect ().Contains (playerInput.GetInvertedMouse ()))
        {
          // Mouse is over
          disableWhenMouseLeaves = true;
        }
        else
        {
          // Mouse is not over
          if (disablewhenMouseLeaves)
          {
            disableWhemMouseLeaves = false;
            myMenu.TurnOff (true);
          }
       }
    }
  • ok. it's working. now there's a question of maintaining an object like this in every scene :/

  • I'm trying to create this script using an instance when i first display the inventory.
    the prefab has a constant ID.

    i added two actions - 
    Object -> check presence
    and set the prefab there 

    then if it's not present i do
    Obejct -> Add

    it works ONCE, then once it added the object to the scene and i stop the game, the prefab gameobject in actionlist dissapears .
    if i don't open the menu, the prefab link stays there as expected...

    if i manually add the prefab to the scene, it re-appears there in the actionlist.

    this is so weird it's like the action list is referenceing the SCENE object instead of the prefab?


    image


    image
  • Look at the Recorded Constant ID number beneath the field reference - that's what matters, if it's visible.  So long as your prefab's Constant ID script has "Retain in prefab" checked, it should work.

    Though with the new features in 1.40, you may be able to do this without a script.  If it works as is, you might want to leave it, but I wonder if this might work as well:
    • Create a Menu of the same size as your Inventory menu
    • Keep it blank, but set it's Appear type to Mouse Over
    • When it turns on, it's because the cursor is over it - so have an ActionList check if Inventory is also on, and set a Global Variable boolean to TRUE
  • the recorded prefab ID is indeed the same and has "retain in prefab" (see below)

    I'll see if i can try that other trick- but can you explain on what do you mean about setting a global variable? 
    maybe what i can do is have a blank menu that appears on mouse over and when it is turned off have an action list that just turns the inventory off instead of keeping booleans. 


    image
  • that extra empty menu with an action to turn off inventories actually did the trick!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.