Forum rules - please read before posting.

Questions about Inventory, Item Handling, ActionListAssets

Hi,

I have a few questions regarding working with the inventory.

I am using a Unity UI Inventory, "Chose interaction then hotspot", cycle through my interactions with the right mouse button and have prefixes turned on on the cursor.

I am sure I am missing something, but I don't get the following to work:

  • the cursor hovering over the inventory item seems to correctly notice the item as a hotspot, but just shows the correct prefix, not the name of the item It works with the standard 2D-Demo-Inventory, but I have no clue why not with my menu. All settings are the same, except that I use Unity UI and my inventory box is called "inventory box 2", as I created it with the original menu still present in the manager...

  • I cannot cycle through the interactions when I am over an item. It immediately plays the Click sound defined in my Inventory box element and then goes back to the standard cursor. This is also not possible in the 2D-Demo, so I wonder if it is possible at all?

  • on my item I defined two interactions, one for use and one for look at. As I understand, only ActionListAssets are allowed here, which is fine, and the use one works without problems. However the examine interaction checks a local variable and this throws the error shown below.
    Is checking local variables not possible in ActionListAssets? Interesting enough, it correctly identifies the varable as the one with ID 2, but it seems the Asset is not allowed to read it?

Maybe anybody has a hint or two for me ;)

Here is the error the ActionList throws:

The 'Variable: Check' Action halted the ActionList because it cannot find the Local Variable with an ID of 2
(From Action #0 in ActionList 'Überbrücker_Examine')

-> AC debug logger
UnityEngine.Debug:LogWarning(Object, Object)
AC.ACDebug:LogWarning(Object, ActionList, Action, Object) (at Assets/AdventureCreator/Scripts/Static/ACDebug.cs:74)
AC.Action:LogWarning(String, Object) (at Assets/AdventureCreator/Scripts/ActionList/Action.cs:1088)
AC.ActionVarCheck:End(List`1) (at Assets/AdventureCreator/Scripts/Actions/ActionVarCheck.cs:172)
AC.ActionList:EndAction(Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:459)
AC.d__34:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:449)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:327)
AC.RuntimeActionList:BeginActionList(Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/RuntimeActionList.cs:186)
AC.ActionList:Interact(Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:195)
AC.RuntimeActionList:DownloadActions(ActionListAsset, Conversation, Int32, Boolean, Boolean, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/RuntimeActionList.cs:141)
AC.AdvGame:RunActionListAsset(ActionListAsset, Conversation, Int32, Boolean, Boolean) (at Assets/AdventureCreator/Scripts/Static/AdvGame.cs:245)
AC.AdvGame:RunActionListAsset(ActionListAsset, Int32, Int32) (at Assets/AdventureCreator/Scripts/Static/AdvGame.cs:166)
AC.RuntimeInventory:RunInteraction(InvItem, Int32) (at Assets/AdventureCreator/Scripts/Inventory/RuntimeInventory.cs:1109)
AC.MenuInventoryBox:HandleDefaultClick(MouseState, Int32, AC_InteractionMethod) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuInventoryBox.cs:1177)
AC.RuntimeInventory:ProcessInventoryBoxClick(Menu, MenuInventoryBox, Int32, MouseState) (at Assets/AdventureCreator/Scripts/Inventory/RuntimeInventory.cs:1915)
AC.MenuInventoryBox:ProcessClick(Menu, Int32, MouseState) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuInventoryBox.cs:2076)
AC.MenuElement:ProcessClickUI(Menu, Int32, MouseState) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuElement.cs:249)
AC.<>c__DisplayClass38_0:b__0() (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuElement.cs:216)
UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent()
AC.OptionalMouseInputModule:Process() (at Assets/AdventureCreator/Scripts/Menu/OptionalMouseInputModule.cs:195)
UnityEngine.EventSystems.EventSystem:Update() (at E:/Apps/Unity/2019.4.9f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)

Comments

  • the cursor hovering over the inventory item seems to correctly notice the item as a hotspot, but just shows the correct prefix, not the name of the item It works with the standard 2D-Demo-Inventory, but I have no clue why not with my menu.

    As in, "Look at" not "Look at item"? What about when you have no interaction cursor active?

    Not sure what you'd get that behaviour. Try relying on the default InventoryBox menu, and switching it back to AdventureCreator as its Source. Does that behave?

    If not, temporarily switch your Settings Manager to Demo2D_SettingsManager, and set the Interaction method to Choose Interaction Then Hotspot. What then?

    I cannot cycle through the interactions when I am over an item.

    How are you cycling - with a right-mouse button?

    I can't recreate such an issue myself with the 2D Demo. Does it work if you instead rely on Adventure Creator for the Inventory menu's Source?

    Try also defining an input named "CycleCursors" in Unity's Input Manager.

    Is checking local variables not possible in ActionListAssets?

    No - local variables are part of the scene, while an ActionList asset is scene-independent.

    You can, however, read Component variable values from assets - though the UI won't display in full if the scene it's a part of is not open. You can create Component variables by attaching a Variables component to a GameObject in the scene.

  • Hi Chris,

    thank you again for helping out :)

    As in, "Look at" not "Look at item"? What about when you have no interaction cursor active?

    Yes, right. Without interaction cursor, nothing is shown. I don't know what I messed up here.

    How are you cycling - with a right-mouse button?

    Yes, right mouse button.
    But this does not work in the demo either, when I load all Managers and open the scene.
    If I take the worm and right-click it, the standard action is performed (Look at), where I would like to change the cursor from "Look at worm" to "Use worm" etc.
    In my case, the cursor switches to the next command and then immediately back to the standard cursor, playing the click sound as if I would pick up the item and put it back immediately.
    If I switch cursor before going to the item, it does the same when I right click.

    You can, however, read Component variable values from assets

    I already use them to keep track of the open/close state of a bunch of lockers, and they are super useful. But aren't they part of the scene, also?
    However in my case, they seemed not really be suitable at the beginning, as I have a scene where I change some booleans about what a player knows, adjusting texts accordingly, and some of these changes also concern items that won't be available in other scenes, so I went with the local variables.

    So maybe I have to redo that part and make a prefab to store these bools as component variables ;)

    Again, thanks for your help!

  • Sorry, just forgot these for the first problem:

    Try relying on the default InventoryBox menu, and switching it back to AdventureCreator as its Source. Does that behave?

    Trying this, the menu still behaves the same, not showing the item names.

    If not, temporarily switch your Settings Manager to Demo2D_SettingsManager, and set the Interaction method to Choose Interaction Then Hotspot. What then?

    With my own Unity UI Inventory, hovering over the item changes the cursor to the standard cursor and nothing is displayed (no prefix text, no item name), and the same when I change the Menu to AC.

    My inventory box is set as default, and changing display type to Text Only, there is nothing shown at all, no image and no text

  • rest of post above:

    My inventory box is set as default, and changing display type to Text Only, there is nothing shown at all, no image and no text

    ... with the Unity UI, while switching my Inventory to AC, the Item name is shown, but in a totally different font than the cursor text, below the cursor text, so I guess it is just the text displayed by the inventory box.

    Icon and Text just works with Unity UI, but this shows only the prefix text again on the cursor, and the item image, not it's name

  • If I take the worm and right-click it, the standard action is performed (Look at), where I would like to change the cursor from "Look at worm" to "Use worm" etc.

    Set your "Inventory interactions" field to "Multiple". When set to "Single", interactions will be limited to left-click to Use/Select, right-click to Examine.

    See if that addresses the labelling issue, too. Otherwise, I'll need to see screenshots of the Game window, Settings Manager, Cursor Manager, and the Menu's properties.

    So maybe I have to redo that part and make a prefab to store these bools as component variables

    Even if it comes from a prefab, only the scene-instance is affected at runtime. AC won't manipulate the values of variables inside prefabs, but you can place an instance of that prefab inside a scene to have an asset access it - provided that it's present, and has a Constant ID component with a value that matches the prefab. (Add a Constant ID component to the prefab and check "Retain in prefab?").

    The technique of having ActionList assets refer to Component variables, though, is best limited to when you want to re-use game logic across different scenes or prefab instances.

    If you're involving data about "what the player knows", I recommend using Global Variables. You can always update Local variables in the scene based on Global Variable values - either through Actions or custom scripting - if need be.

  • Thanks again, Chris.

    Set your "Inventory interactions" field to "Multiple".

    Ok, I forgot to set this in the 2D-Demo, and with it, it works.

    As I already set the Inventory Actions to Multiple in my own menu, I prepared some screenshots, maybe they can help:

    Inventory from the game screen: https://i.imgur.com/0ZZ5Ysw.png

    Settings Manager: https://i.imgur.com/JMG19Gr.png

    Cursor Manager: https://i.imgur.com/eeRQ9Wj.png

    Menu Manager & Menu: https://i.imgur.com/T4HIBzp.png

  • edited September 2020

    The issue in the screenshot is referring to the position of the Hotspot label?

    If the Hotspot menu has a Position type of On Hotspot, it will position itself above the active inventory item as well. However, wherever it appears, it will be subject to boundary-checking if Always fit within screen? is checked.

    Note that this option refers to the boundary of the Menu - not the element(s) inside it. When using Unity UI, it's specifically dealing with the RectTransform boundary property - which should typically be the first immediate child of the Canvas in the prefab.

    Is the Hotspot menu similarly rendered with Unity UI? If so, you'll need to configure the prefab with a Content Size Fitter component or similar to re-size the "RectTransform boundary" based on the amount of text being shown in the Hotspot label.

  • The issue in the screenshot is referring to the position of the Hotspot label?

    No, although you're right, position is a bit off, it was just about the missing item name.

    Hotspot and Interaction are currently still AC menus.

    The Hotspot Menu has Position type On Hotspot, and Always fit within screen? is checked. When I disable it, the verb begins outside the screen for the first item, so it is not readable completely.

  • If a Menu has the potential to be repositioned by the screen edge, don't uncheck Always fit within screen?, as it'll then be possible to be displayed over the boundary.

    You can switch the Size properties of both the Menu and Label elements to Automatic, but dynamic resizing is better handled by Unity UI.

    Following your screenshots, I have encountered an issue when right-clicking to cycle interactions while hovering over the inventory. I shall look into this, but I cannot recreate the issue of the item's name being missing. Likely you'll need to PM me a .unitypackage of your Manager and UI graphical assets so that I can see things for myself.

  • Ok, I guess I managed to put the relevant pieces into a package, I will PM it to you, thank you very much for your help ;)

  • Chris pointed me to the very easy solution for the problem of the missing item name when hovering over my inventory.

    So in case anybody might face the same problem:

    As the menus are drawn in the order they are displayed in the manager, I just had to move the Hotspot Menu below my newly made Inventory Menu, so that it has access to the names.

    I found a hint about it in the Manual at the Hotspot Menu under default interfaces, maybe a more prominent info on this, maybe in the Note according drawing order found under Menus overview, it might be a good idea to point out that certain menus depend on others to be before them, like the Hotspot on the inventory.

    If one, like me, starts creating his own inventory first and doesn't care about the Hotspot menu yet, it is automatically last in the list and the hotspot menu does not work like intended ;)

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.