Forum rules - please read before posting.

Switching to CHTI Interface affects Inventory functionality

Hi Chris and AC enthusiasts!

Unity v.2019.3.0f6
AC v.1.70.3

I very recently switched the Interface settings from Context Sensitive to Choose Hotspot then Interaction (CHTI) for more flexibility.

Settings:
https://imgur.com/CYVY52B

So I now right mouse click on each hotspot and cycle through the available interactions. E.G. Examine 'hotspot 1', Talk to 'hotspot 1', Examine 'hotspot 2', Go to 'hotspot 2' etc. It works great and displays the correct text and the correct cursor icons. Then left click to trigger the interaction - brilliant!

But, the interactions with my inventory are now not working at all, and it seems the more I play around with it, the more I'm trashing it. I couldn't find exactly what I want anywhere in the forum, so I'll describe how I'd like it to work and show you my current set up. I'm really hoping to avoid scripting if possible. Or possibly a more simple set up would be better.

Below is a picture of my inventory bag. I might redesign it but it has the features I would potentially use if going for option 1. It is accessed by clicking on a Bag menu icon from within the game which opens a new menu called Inventory. This pauses the game.

https://imgur.com/zl58uQd

OPTION 1
So rather than assigning interactions to each inventory item specifically (which only seems to work for examine anyway), I would like to click on a specific inventory item, the item is highlighted and stays highlighted, you then move the cursor to the right hand side of the bag which displays the various options:

Examine - displays text describing the object (I do worry whether this could be displayed in front of the pause menu reduced opacity blacked out screen so it can be read okay).
Use - This will close the inventory menu and the player will be 'holding' the inventory item and can click on hotspots within the game to trigger interactions. I don't think drag and drop would work here (drag and drop was what I was using before).
Combine - Text appears 'Combine 'item 1' with...' and the player will select another item within the inventory bag. I don't really need a crafting menu as only maximum of two objects will be combined at any one time. When both items are selected, they will disappear and be replaced with the new combined inventory item.

Or if the above is too complicated the other option I've been considering is:

OPTION2
Within the Inventory menu, right click an inventory item to cycle through the possible interactions and then left mouse click to select - very much how the CHTI works in the main game.
Examine would display text to describe the object (I've got that working) by assigning that interaction to the specific inventory item. I'm not able to right click to cycle through other interactions though, nothing happens.
Use - I would still want the Inventory menu to close and for the item to be selected to drop onto a hotspot.
Combine would be another right click cycle interaction and text would be displayed 'Combine 'item x' with... and then you select the other inventory item (I've not created a cursor icon for this as hoping text will be sufficient).

Maybe option 2 would be better.

Screenshots below of the relevant managers. Let me know if you need anything additional. And apologies for the massive post!

https://imgur.com/i8tfPqd
https://imgur.com/EoGM0v9
https://imgur.com/Ejr4WHd
https://imgur.com/rLZJKFq
https://imgur.com/Ch77EJ1
https://imgur.com/YI6uH0u
https://imgur.com/DlxSwDL
https://imgur.com/wOuV977
https://imgur.com/buYeDfU
https://imgur.com/AB1rF1n
https://imgur.com/NkFo3uL
https://imgur.com/FZiFziG
https://imgur.com/ItvoIAr
https://imgur.com/XK4x8hD

Many thanks
Caroline

Comments

  • edited September 2020

    Option 1

    This is certainly the more complex of the two. While possible, it would require custom scripting. Particularly if you want to allow for drag-dropping items onto Use/Examine, the easiest way is likely to make your Use/Examine buttons Inventory items themselves (so that there's a reaction to dropping an item onto them) - and then use custom scripting to hook into the OnInventoryCombine custom event.

    If you create two Inventory categories, "Normal" and "Interaction", you can place these Use/Examine items into the "Interaction" category and hide them from your regular inventory by limiting your Inventory to only show "Normal" items.

    The "Combine" button would be more complex still. If you want to go down the route of Option 1, best start with the Use/Examine aspect first. I can advise further if so, but best to get an idea from you first which option you want to go with.

    Also note that the upcoming v1.72.0 update will make improvements to AC's Inventory system, making it (hopefully) much easier to script custom inventory systems.

    Option 2

    So long as your Inventory interactions setting is set to Multiple, then inventory interaction behaviour should be much the same as Hotspots. Currently there is an issue with the right-clicking of items if Reset cursor after an interaction? is checked. This will be addressed in v1.72.0.

    To "Use" an item to have it close the menu and select the item, you could either automate it through scripting, or do it with a Menu: Change state Action followed by an Inventory: Select Action.

    Again, combining in the manner you intend would need some scripting. The "built-in" way of combining items in this setup is to include the combining item as part of the array of cursors you can cycle through. Again, it's best to start with the Use/Examine mechanic of your preferred choice and go from there.

  • Ok thanks Chris. I'll update to v1.72.0 when available, and see how I get on. I'm sure I'll have more questions once I've chosen the option I intend to progress with.

  • Hi Chris.

    I'm going with Option 2 however, I still can't right click through the interaction cycles on inventory objects. I can't work out what's wrong. It defaults to whatever 'Standard Interaction' I have per Inventory item.

    My Inventory interactions setting is set to Multiple. Also I can't even find where 'Reset cursor after an interaction?' is

    I also tried the 'Menu: Change state Action followed by an Inventory: Select Action' but was presented with this message:

    Inventory items cannot be selected with this combination of settings - they are included in Interaction cycles instead.

    I think I'll be happy with the "built-in" way of combining items in this setup is to include the combining item as part of the array of cursors you can cycle through as you mention above.

    I haven't changed any settings (I don't think) since my screenshots above.

    Screenshots of my inventory:

    https://imgur.com/1tuyoAO
    https://imgur.com/6aqYOvt

    Many thanks

  • What AC version are you now using? Have you imported v1.72.0?

    I can't even find where 'Reset cursor after an interaction?'

    My mistake - it's labelled Auto-cycle after an Interaction? when using Choose Hotspot Then Interaction mode.

    Can you share a screenshot of your full Settings Manager? I'll attempt a recreation.

  • Yes I have v1.72.0 imported. Just to note that I'm using Dialogue System as well and Tony gave me a couple of downloads to sort out compile errors.

    Link here:https://www.pixelcrushers.com/phpbb/viewtopic.php?f=3&t=3590&sid=229b450a5ceb562f0a884a76de289240

    I've tried switching the Auto-cycle after an interaction? off too and it didn't seem to affect anything.

    https://imgur.com/RpOdltX
    https://imgur.com/uDD6HBO
    https://imgur.com/NlJAtpO
    https://imgur.com/VUMU1pq
    https://imgur.com/8CAlIQg

    Thanks

  • Thanks for the details.

    You should not need to use the Inventory: Select Action in this interaction setup - items listed in the "Combine interactions" panel should be included in the cursor cycle when right-clicking.

    In the case of your example "Daphne" item, right-clicking should select the following cursor modes in this order:

    • Examine
    • Use
    • Use (again, since you've two defined)
    • Daphne item
    • Toothbrush item

    This is the behaviour I'm getting when testing a new game with your settings, though.

    I still can't right click through the interaction cycles on inventory objects. I can't work out what's wrong. It defaults to whatever 'Standard Interaction' I have per Inventory item.

    Can you explain fully what the behaviour is with the above "Daphne" item? What happens to the cursor when you hover over it, what happens when you left-click it, and what happens when you right-click it?

  • Hi Chris.

    Just to avoid any confusion (as I'm a bit confused), I'll state what I expect (and want) to happen and list what actually happens.

    During gameplay right clicking on hotspots cycles through the available interactions as expected. I do not want inventory items to appear in the cycle. The only interactions I'd expect are things like Examine, Talk to, Go to, Use. For each hotspot in the game I am not adding 'Inventory Interactions'.

    Inside the Inventory Box Examine hovering over the inventory items displays the first interaction I've set up, in this case 'Examine'+ 'inventory item'. Right clicking does nothing at all. When I left click on 'Examine Daphne' it displays the text 'It's Daphne' without turning the inventory menu off (that works how I want it). Images below:

    https://imgur.com/sq4QvZZ
    https://imgur.com/FwUosxw
    https://imgur.com/F4DPVwa

    My inventory box is set to 'Default', does that matter? If I set it to 'Hotspot', all items disappear apart from the first item (the toothbrush)

    The interactions per inventory within the inventory box will be Examine, Use and Combine

    Inside the Inventory Box Use Once use is working I'd like to be able to turn the menu off, hold the item and drop it on hotspots in the game.

    Inside the Inventory Box Combine Combine will hold the item and not turn off the inventory box and I'd like to be able to drop the item onto another inventory item.

    Is any of this going to be possible without scripting as I'm terrible at it?

    And I found some odd behaviour when I right clicked on the mouse twice anywhere on the screen in the game without a hotspot, it displayed the toothbrush as a held item to be used on a hotspot. I did have an interaction script that turned off the menu and held the item but I deleted it, saved the game, closed unity and then re-opened the game. It persists. Screenshot below.

    https://imgur.com/a7Sgriq

    Many thanks
    Caroline

  • Right clicking does nothing at all.

    This should be possible given your settings.

    It may be some minor difference that's too hard to see just by screenshots. If you can create a .unitypackage that I can use to experience it for myself, PM it to me and I'll take a look.

    I would need your Manager asset files, graphics and ActionLists associated with your Daphne item and Inventory menu.

    Is any of this going to be possible without scripting as I'm terrible at it?

    I can assist if scripting is necessary, but with your combination of settings, the expected behaviour is that items will behave like Hotspots. Right-clicking on them should cycle through the interactions - combines included.

    In this mode, items are not selected directly - but instead included in cursor cycles.

    If you want to instead be able to select items so that you can then use them on other items or Hotspots, you'll need to uncheck Include Inventory items in Hotspot Interaction cycles?. Doing so will allow you to use the Inventory: Select Action, and also configure Use interactions to do this automatically.

    That may get you closer to what you're looking for. The main difference between Use vs Combine - that I'm seeing from your description - is that they both select an item, but Combine doesn't close the Menu.

    when I right clicked on the mouse twice anywhere on the screen in the game without a hotspot, it displayed the toothbrush as a held item

    That would be a bug if that's coming from AC, but I can't picture how that might be occuring. We can learn the source of this if you open up the RuntimeInventory script, and search for the line:

    KickStarter.eventManager.Call_OnChangeInventory (null, selectedInstance, InventoryEventType.Select);
    

    Immediately below it, paste the following:

    Debug.Log ("Selected item " + selectedInstance.InvItem.label);
    

    That will display a message in the Console whenever an item is selected. What is the entire message that shows when you select an item in this way?

  • Hi Chris.

    I sent the package over to you.

    Appreciate the help I might need with scripting in due course.

    And regarding the odd behaviour when I right click on a space in the game with no hotspots (I pasted the line of code provided), I receive this message:

    Selected item Toothbrush
    UnityEngine.Debug:Log(Object)
    AC.RuntimeInventory:SelectItem(InvInstance, SelectItemMode) (at Assets/AdventureCreator/Scripts/Inventory/RuntimeInventory.cs:217)
    AC.RuntimeInventory:SelectItemByID(Int32, SelectItemMode, Boolean) (at Assets/AdventureCreator/Scripts/Inventory/RuntimeInventory.cs:159)
    AC.PlayerInteraction:OffsetInteraction(Boolean) (at Assets/AdventureCreator/Scripts/Controls/PlayerInteraction.cs:1880)
    AC.PlayerInteraction:SetNextInteraction() (at Assets/AdventureCreator/Scripts/Controls/PlayerInteraction.cs:1820)
    AC.PlayerCursor:UpdateCursor() (at Assets/AdventureCreator/Scripts/Controls/PlayerCursor.cs:199)
    AC.StateHandler:Update() (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:162)

    Many thanks
    Caroline

  • Thanks, I'll look into it.

  • For the benefit of everyone who has the same issue, 'Right clicking does nothing at all in the inventory menu' it was because my Inventory menu had the 'Pause game when enabled' ticked.

    when I right clicked on the mouse twice anywhere on the screen in the game without a hotspot, it displayed the toothbrush as a held item

    This seems have resolved itself. ^

    If you want to instead be able to select items so that you can then use them on other items or Hotspots, you'll need to uncheck Include Inventory items in Hotspot Interaction cycles?. Doing so will allow you to use the Inventory: Select Action, and also configure Use interactions to do this automatically.

    That may get you closer to what you're looking for. The main difference between Use vs Combine - that I'm seeing from your description - is that they both select an item, but Combine doesn't close the Menu.

    I've unticked the Include Inventory items in Hotspot Interaction cycles? and I'm able to now close the Inventory Menu when choosing Use interaction but using the **Inventory: Select Action in an ActionList does nothing. I'm not sure what else to do?

    Using the Combine Interactions in the Inventory menu also seems to do nothing too. I think I'd expect this to 'select the item' and display the text 'Combine item with xxx'. Where the combination is possible I'd want both items to be removed and replaced with the new combined item which appears to be possible via ActionList. And if not possible, display the unhandled text.

  • This seems have resolved itself

    It's dependent on the Include Inventory items in Hotspot Interaction cycles? option, so if you unchecked that then it'll likely disappear. I shall provide a fix in the next update, though.

    the Inventory: Select Action in an ActionList does nothing. I'm not sure what else to do?

    That should be enough - and testing on my end shows no issue. Can you share screens of the ActionList and where you've assigned it?

    Using the Combine Interactions in the Inventory menu also seems to do nothing too. I think I'd expect this to 'select the item' and display the text 'Combine item with xxx'

    That's how it should work, though you first need to have an item selected before you can combine it with another.

    As an alternative to using an Action to manually select an item, you can also check Select item if Interaction is unhandled? in the Settings Manager and assign the Use cursor. Then, create a new Use interaction for your Inventory item, but don't assign an ActionList. "Using" that item should then auto-select it.

    Where the combination is possible I'd want both items to be removed and replaced with the new combined item

    A pair of Inventory: Add or remove Actions can do this - one to replace the first item with the new one, and another to remove the second item.

  • That should be enough - and testing on my end shows no issue. Can you share screens of the ActionList and where you've assigned it?

    I've got Use working. I had to tinker with the Inventory settings within the Settings Manager, but it's working! :) This is what I have now:

    https://imgur.com/dq2MVqO

    I've also got Combine working although if possible a minor change would neaten it up.

    What happens now:

    In the Inventory menu I right click cycle until I come to the Combine standard interaction I set up
    I left click to select Daphne item
    I am now holding Daphne in the Inventory menu
    I then hover Daphne over another inventory item (toothbrush). The text is displayed as Use Daphne on Toothbrush which is fine, but would it be possible for the text to read Combine Daphne with Toothbrush? Just for consistency but, if it's not easy to do then I'm happy with the Use a on b.
    I then set up an ActionList to remove the Toothbrush item and replaced Daphne with a new inventory item.

    I will have another interaction called Read but that should be easy enough to do. I was planning on closing the inventory menu and then switching scenes to the scene with the specific document (which will fill the whole camera view). I can then add a switch to previous scene action once the document has been read and the player wishes to return to the gameplay by pressing a back button. I've already got something similar set up.

    Thanks very much for your help on this!

    Have a great rest of the week
    Caroline

  • would it be possible for the text to read Combine Daphne with Toothbrush?

    Yes - you can override the "Use X with Y" syntax either globally in the Cursor Manager, or per-item in the Inventory Manager by checking Override 'Use' syntax?.

    I was planning on closing the inventory menu and then switching scenes to the scene with the specific document

    Switching the Player to and from another scene would cause them to be placed at a PlayerStart upon re-entry. Instead, it's probably better to rely on player-switching to handle the scene transitions.

    If you enable player-switching, you can create an "invisible" Player prefab that is only ever active when viewing a document. When it's time to view the document, you can then use the Player: Teleport inactive Action to place them in the document scene, then the Player: Switch Action to switch to that player and - in turn - the document scene.

    When you're then ready to go back to normal gameplay, you can then use another such Action to return to your regular Player and have them be in the same place as you left them.

  • Thanks Chris

    Yes - you can override the "Use X with Y" syntax either globally in the Cursor Manager, or per-item in the Inventory Manager by checking Override 'Use' syntax?.

    So I still want the Use Daphne on hotspot in the game, but I would like to have the separate Combine Daphne with inventory item within the Inventory menu. Is that possible?

    Switching the Player to and from another scene would cause them to be placed at a PlayerStart upon re-entry. Instead, it's probably better to rely on player-switching to handle the scene transitions.

    Yes I had this issue before and got it working and I think you've updated how players switch in a recent release so I'll see how I get on with it. I already have player switching enabled so I should be okay with this.

    Thanks again
    Caroline

  • So I still want the Use Daphne on hotspot in the game, but I would like to have the separate Combine Daphne with inventory item within the Inventory menu.

    Possible, but a bit of scripting would be needed. Are you looking to have that syntax for all items, or just Daphne?

    I think you've updated how players switch in a recent release so I'll see how I get on with it

    Yes, it was changed quite drastically - though this video covers the key points.

  • Possible, but a bit of scripting would be needed. Are you looking to have that syntax for all items, or just Daphne?

    All items would be useful. Daphne was just a test inventory item anyway. But in my game there will be at least one scenario where two inventory items are combined to create a new item. That item with then be used on a hotspot in the game. Then that item will be combined with another inventory item to be used in the game.

    E.G
    Combine magnet with thread = magnet on a thread
    Use magnet on a thread on hotspot 'A' in the game
    Combine magnet on a thread with feather = cat toy
    Use cat toy on hotspot 'B'

    Yes, it was changed quite drastically - though this video covers the key points.

    Great, thanks I will watch that video over the weekend!

    Many thanks
    Caroline

  • It may need some tweaking, but this script - placed in the scene - should override the default syntax when hovering an item with another item selected:

    using UnityEngine;
    using AC;
    
    public class CustomCombineSyntax : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnRequestMenuElementHotspotLabel += My_Override; }
        private void OnDisable () { EventManager.OnRequestMenuElementHotspotLabel -= My_Override; }
    
        private string My_Override (Menu menu, MenuElement element, int slot, int language)
        {
            if (menu.title == "Inventory" && element is MenuInventoryBox)
            {
                MenuInventoryBox inventoryBox = (MenuInventoryBox) element;
                InvItem selectedItem = KickStarter.runtimeInventory.SelectedItem;
                if (selectedItem != null)
                {
                    InvItem slotItem = inventoryBox.GetItem (slot);
                    if (slotItem != null)
                    {
                        return ("Combine " + selectedItem.label + " with " + slotItem.label);
                    }
                }
            }
            return string.Empty;
        }
    
    }
    
  • Hi Chris.

    That was quick!

    It works as expected, thanks so much! Awesome!

    Just to ensure my understanding is correct about adding custom scripts like this.
    I added a new empty GameObject to the scene and attached the script to it. I named the CustomeCombineSyntax.cs and added it to a new folder I named 'Scripts' within my game folder.

    Thanks again, you're an absolute gem!

    Caroline

  • edited October 2020

    No problem!

    That'll work for the scene it's in. It'll have to be present in any scene you want it to work for.

    The easiest way to do this is to add it to the PersistentEngine prefab in the /AdventureCreator/Resources folder, as this is spawned in the scene at runtime automatically.

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.