Forum rules - please read before posting.

Default inventory interactions

Hi! I took a long break from a project and recently went back on it wanting to simplify it, since this is a mobile project and I think the amount of scripting and "surprises" I had with Unity are way beyond the scope of what I can work with. So this is what I am aiming towards at the moment.

  • keep choose hotspot then interaction
  • only show available interactions when you click a hotspot.
  • hotspot label should be visible when you interact.
  • inventory works as drag & drop, whether it is for interacting with hotspots or combining items.
  • i would like to be able to choose the only available interaction upon drag & drop. let's say I have a key and my door hotspot has only a "use" interaction, it will show that & label that as a "use key in door". now if I have an apple and I want to give it to a dog, and I have that give interaction ready on the dog's hotspot, then it will choose the "give" interaction when dragging item, and the hotspot label will show "give apple to dog".

my only problem is that so far, dragging inventory items always defaults to Use interactions (whether there actually is one or not)... so I get "use apple in dog" instead of give. I've tried all I can remember but I couldn't find a solution.

am I forgetting something or this can't be done?

Thanks in advance.

Comments

  • Does your Dog Hotspot's Inventory interaction have the option to select Use vs Give? This option will only appear if your combination of interface/inventory settings allow for it.

    I'll attempt a recreation. Can you share your AC/Unity version numbers, as well as screenshots of your Settings Manager as well as a typical Hotspot?

  • In my actual game, I have a cup of coffee and a woman. Player needs to combine coffe with milk (which works fine), and then drag it onto the woman to give it, but I get "use" instead of "give".
    "Give" works if I have "multiple inventory interactions" in settings, but that is what I am trying to avoid.
    In the woman's hotspot there are 2 use interactions for "talk to" and "look at", and 2 inventory interactions (of type Give) for items "coffee" and "mik coffee".

    I thought of making the whole game context sensitive but I will lose a lot of possible interactions / exploration. Ideally, player should be able to choose hotspot then interaction, while inventory items would automatically select the only available interaction for each hotspot.

    I am using Unity 2019.4.0f1 and AC 1.72.4

    Screenshot of woman's hotspot and settings: https://drive.google.com/file/d/1-X4sq_VQj_kT7awpHdVorW61PBgmib75/view?usp=sharing

  • Thanks for the details - I'll look into this.

  • Recreated.

    It's possible to change the manner in which an item is selected (use vs give) when selecting an item via the Inventory: Select Action. But with this combination of settings, it's best to rely on a simple script to handle the automatic switching between these two options depending on the active Hotspot.

    This should do it. Attach to a GameObject in your scene:

    using UnityEngine;
    
    namespace AC
    {
    
        public class AutoSetItemMode : MonoBehaviour
        {
    
            private void OnEnable () { EventManager.OnHotspotSelect += OnHotspotSelect; }
            private void OnDisable () { EventManager.OnHotspotSelect -= OnHotspotSelect; }
    
            private void OnHotspotSelect (Hotspot hotspot)
            {
                if (InvInstance.IsValid (KickStarter.runtimeInventory.SelectedInstance))
                {
                    Button invButton = hotspot.GetInvButton (KickStarter.runtimeInventory.SelectedInstance.ItemID);
                    if (invButton != null)
                    {
                        KickStarter.runtimeInventory.SelectedInstance.SelectItemMode = invButton.selectItemMode;
                    }
                }
            }
    
        }
    
    }
    
  • Thank you so much for your help, Chris, that worked. The only problem is I realized I also needed to select Give if hotspot was a Character and interaction was unhandled, so using your example I added a few lines and got it to behave like I needed:

    using UnityEngine;
    
    namespace AC
    {
    
        public class AutoSetItemMode : MonoBehaviour
        {
    
            private void OnEnable() {EventManager.OnHotspotSelect += OnHotspotSelect; }
            private void OnDisable() {EventManager.OnHotspotSelect -= OnHotspotSelect; }
    
            private void OnHotspotSelect(Hotspot hotspot)
            {
    
    
                if (InvInstance.IsValid(KickStarter.runtimeInventory.SelectedInstance))
                {
                    Button invButton = hotspot.GetInvButton(KickStarter.runtimeInventory.SelectedInstance.ItemID);
    
                    if (invButton != null)
                    {
                        KickStarter.runtimeInventory.SelectedInstance.SelectItemMode = invButton.selectItemMode;
                    }
    
                    if (invButton == null)
                    {
                        if (hotspot.GetComponentInParent<AC.Char>())
                        {
                            KickStarter.runtimeInventory.SelectedInstance.SelectItemMode = AC.SelectItemMode.Give;
                        }
    
                        else
                        {
                            KickStarter.runtimeInventory.SelectedInstance.SelectItemMode = AC.SelectItemMode.Use;
                        }
                    }
                }
            }
        }
    
    }
    
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.