Forum rules - please read before posting.

Adding the ability to "present evidence" mid-conversation?


I'm a new-ish user of AC, and I've finally run into my first problem I haven't been able to satisfactorily solve with the tutorials and manual. That, or I'm unclear on where to look.

I'm playing with the system and making a detective-ish adventure game. I want the ability to open up a particular inventory in the middle of a conversation, when prompted, and to present the proper piece of "evidence" to continue. While I could do this by making a conversation tree where certain options only open up when you have the right item, that doesn't quite capture what I want. I want part of the puzzle to be figuring out which piece of evidence you need to present (a la "Ace Attorney") and for that, I'd need access to the entire relevant inventory and the ability to use it in a conversation.

Is there a nice, clean way of doing this? Longer-term, I intend to make a specific menu template that'll serve as the "evidence" inventory, but for now, I want to get this interactivity in the conversations.



  • Welcome to the community, @CJWilson.

    It's possible to limit a Conversation option's display according to whether or not the Player is carrying a specific item. One approach you could take would be to create such an option for each item (irrelevant ones could be all set to run the same Actions). These options could be moved to a separate Conversation (and Conversation menu) to have them appear in a separate UI to your regular dialogue tree.

    Otherwise - if you wanted to instead bring up a regular Inventory box and have the Player choose from them - you could rely on custom scripting to determine what happens when the Player clicks on a given item.

    Perhaps what you could do is a hybrid of the two - where an InventoryBox menu element is shown (and has custom click behaviour driven by script), but clicking an item will check to see if a given Conversation has an option linked to that item. Otherwise, a "fallback" ActionList could be run.

    I can advise further if this sounds like the right approach for you.

  • So, if I understand the hybridization option right: that would open up an InventoryBox menu element, then clicking items that do have a conversation option would carry you forward in the dialogue as though you clicked the right conversation option. Meanwhile, if you click one that doesn't, I could make the character say some default "I don't understand what you're showing me" text?

    If so, that seems like a good bet. I wanted the evidence presentation to be visual and based on icons, and figured out how to make the inventorybox menu show, but couldn't find my way past that stage. Help along that hybrid option you proposed would be golden.

    Thank you so much!

  • edited January 27

    That's what I was getting at, yes.

    It might take a bit of tweaking, but try this:

    1. Create a new Menu named "Evidence"
    2. Set its Appear type to During Conversation. and check Start game locked off?.
    3. Add an InventoryBox element, and set its Inventory box type to Custom Script.
    4. Create a new Conversation that only has the options for using items (no "regular" speech options).
    5. Copy/paste the code below into a C# script named EvidenceMenu, and attach the new Evidence Menu component to the above Conversation.
    6. Assign an ActionList in its Inspector to run when no appropriate option is found
    7. To show the list of items, use a regular Dialogue: Start conversation Action to run the new Conversation.


    using UnityEngine;
    using AC;
    public class EvidenceMenu : MonoBehaviour
        public ActionList unhandledResponse;
        private const string normalConversationMenu = "Conversation";
        private const string evidenceConversationMenu = "Evidence";
        private bool isRunning;
        void OnEnable ()
            EventManager.OnStartConversation += OnStartConversation;;
            EventManager.OnEndConversation += OnEndConversation;;
            EventManager.OnMenuElementClick += OnMenuElementClick;
        void OnDisable ()
            EventManager.OnMenuElementClick -= OnMenuElementClick;
            EventManager.OnStartConversation -= OnStartConversation;;
            EventManager.OnEndConversation -= OnEndConversation;;
        void OnStartConversation (Conversation conversation)
             isRunning = (conversation.gameObject == gameObject);
             if (isRunning)
                PlayerMenus.GetMenuWithName (normalConversationMenu).isLocked = true;
                PlayerMenus.GetMenuWithName (evidenceConversationMenu).isLocked = false;
        void OnEndConversation (Conversation conversation)
            isRunning = false;
            PlayerMenus.GetMenuWithName (normalConversationMenu).isLocked = false;
            PlayerMenus.GetMenuWithName (evidenceConversationMenu).isLocked = true;
        void OnMenuElementClick (Menu menu, MenuElement element, int slot, int buttonPressed)
            if (!isRunning) return;
            MenuInventoryBox inventoryBox = (MenuInventoryBox) element;
            if (inventoryBox == null || inventoryBox.ParentMenu.title != evidenceConversationMenu || inventoryBox.inventoryBoxType == AC_InventoryBoxType.CustomScript) return;
            InvItem clickedItem = inventoryBox.GetItem (slot);
            if (clickedItem == null) return;
            Conversation conversation = GetComponent<Conversation> ();
            foreach (ButtonDialog buttonDialog in conversation.options)
                if (buttonDialog.isOn && buttonDialog.linkedInventoryID ==
                    conversation.RunOptionWithID (buttonDialog.ID);
            if (unhandledResponse) 
                conversation.TurnOff ();
                unhandledResponse.Interact ();
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.