Forum rules - please read before posting.

Customizing Menus

Hello there, I ran into some challenges with the 9 verbs menu template. For my game I want the verbs 'look at' and 'talk to' to trigger different events depending on the chosen language by the player. Therefore I made a menu called 'language picker' to pop up every time I trigger a 'look at' or 'talk to' action event. But AC doesn't wait for the player to pick a language, but runs straight through the whole action. Another problem is, how I can make the game automatically close a menu when the cursor leaves the hot spot or the menu itself. And last, is there a way to change the 9 verbs of the menu in runtime, for example when the player triggers an action? For example, if player triggers event -> change 'look at' to 'uită-te'.
Regards, Mike

To hopefully make it a bit clearer what I mean, I made a little video. about 6 minutes.

Comments

  • With your custom "Language picker" Menu, your ActionList is set to run the Variable: PopUp switch Action immediately after the Menu: Change state Action, so the behaviour you're getting looks like it matches up with the Action logic.

    If you want to have the ActionList "wait" until the player's chosen an option, one way would be to disconnect the Menu: Change state Action from the rest of the chain, and then re-run the ActionList once an option has been chosen - starting with the Variable: PopUp switch Action. This can be done with the ActionList: Run Action.

    However, I'd say this would be a good case for using a Conversation instead. A Conversation menu needn't display a list of dialogue options - it's just a way of presenting the player with a list of options. It's also possible to rely on icons instead of text for the display of these options.

    If you create a new Conversation, and add the two languages as new dialogue options, then you can use the Dialogue: Start conversation Action in place of the Menu: Change state and other Actions. This Action can be used similarly to the Variable: PopUp switch Action, in that you can reroute your ActionList to run different responses based on the player's choice - a tutorial can be found here.

    For a Conversation to show, you'll need a Menu contains a DialogList element, and has an Appear type set to During Conversation. The default interface comes with such a Menu, though you can duplicate it and alter it to look like the "Language picker" menu you currently have. This menu won't need to have its UI Image/Button component's pre-assigned with the correct textures - AC's DialogList element will automatically populate the Buttons with the correct graphic based on the Conversation, so you can re-use the same Menu for any such Conversation.

    The "click handling" of UI prefab objects is handled via the various Elements that they link to via the Menu Manager. A tutorial on linking UI prefabs to AC menus can be found here.

    Though, working with Unity UI and Menus together is another layer of complexity. While prototyping, it may be easier to swith your Menu's Source to Adventure Creator, which does away with the need for UI prefabs as AC itself handles rendering duties. You can always switch back to Unity UI once things are fundamentally working.

    On having the Menu close as the cursor leaves the Hotspot: that is a built-in behaviour for Menus with an Appear type of On Hotspot and On Interaction. That won't be something you can use for your Conversation menu, but you can use custom scripting to get similar behaviour.

    In the case of a Menu with an Appear type of During Conversation, it will show whenever a Conversation is active. Therefore, a custom script can be used to "turn off" a Conversation object it's attached to when the mouse is not over a Menu or a Hotspot - and this will cause the Conversation menu to turn off:

    using UnityEngine;
    using AC;
    
    public class AutoHideConversation : MonoBehaviour
    {
    
        private void Update ()
        {
            if (KickStarter.playerInput.activeConversation && KickStarter.playerInput.activeConversation.gameObject == gameObject)
            {
                if (!KickStarter.playerMenus.IsMouseOverMenu () && KickStarter.playerInteraction.GetActiveHotspot () == null)
                {
                    KickStarter.playerInput.activeConversation.TurnOff ();
                }
            }
        }
    }
    

    When it comes specifically to event hooks, AC features a custom event system that allows you to "hook" custom code into common events that AC performs. A tutorial on this topic can be found here.

  • edited April 2022

    Hey, thanks again chris. You got some very interesting solutions for my problem. I'll go for the conversation option first. That sounds very promising.

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.