Forum rules - please read before posting.

Inventory and Hotspot custom control

edited February 2018 in Technical Q&A

Hi, I am struggling to make a custom inventory and hotspot control. I am trying to make these work:


1) How to hide the "Menu" icon on the lower left corner?


2) I wish to totally control the game by keyboard / controller. I managed to toggle the inventory menu with a key input, but cannot select or "scroll" through the items by keys even with the "Auto-select first visible Element?" checked and "Include Inventory items in Hotspot Interaction
menus?" unchecked.


3) Is it possible to interact with Hotspots and items like:

When a hotspot is detected, key input are used to determine the action performed (e.g. "z" for the "use" action, and "x" for the "look at" action)

Similarly for inventory, when an item is selected, different key inputs can be used to perform different actions on the item.


4) How to give customer interaction to Hotspots (in additional to "use", "look at" and "talk") as well as items in inventory?


Below are my settings for Hotspot & Inventory menu, and the interface and inventory settings:

image

image

image

image


Thank you very much for your help.

Comments

  • 1) That's the "InGame" menu, and can be deleted (or locked off so that it doesn't show) by editing it in the Menu Manager.

    2) The Include Inventory items in Hotspot Interaction menus? option only applies to InventoryBox elements that appear in an Interaction menu (i.e. a Menu that has an Appear type of On Interaction).

    If you check the Inventory Menu's Pause game when enabled? property, does it then work?  If you don't want it to pause the game then you'll have to use the Engine: Manage systems Action to allow control of it during gameplay.  For more on this, please see the "Navigating menus directly" chapter of the Manual.

    3) Change the Select interactions by field to Clicking Menu.  This is what the 2D Demo uses, however that relies on the mouse.  In order to map interaction types to the keyboard, find the Interaction menu in your Menu Manager, and define an Alternative input button for each icon element.  The input names will have to match those you add in Unity's Input manager, but if you press an input while an Interaction icon is visible on-screen, it'll be triggered as though you were clicking it with the mouse.  See the "Interaction elements" chapter of the Manual for more.  In order for Inventory items to have multiple interactions as well, change the Inventory interactions field to Multiple - see "Inventory interactions" in the Manual.

    4) Interaction types can be managed in the Cursor Manager - see "The Cursor Manager" chapter in the Manual.
  • edited February 2018
    1) Thanks, I didn't realize it is so easy lol

    2) I cannot interact with the inventory bar items no matter the choice of Pause game when enabled? option. 

    Actually after the inventory bar is shown, no item seems to be selected for what I tried (including using Auto-select first visible Element?, click on the inventory bar, or using the direction key). The selected item should have a green background by default right? I couldn't get that up. I observed that if I use Unity UI prefab, when I click on the inventory bar in Unity Game window (even my game cursor is disabled and Inventory menu has Ignore Cursor Click? on), then use my direction key to go left or right, at some point I can see the Shift Left and Shift Right arrow icons light up. But I can never get the items selected.

    This stays the same when I use either Automatic or Manual control for the player

    I tried using an ActionList for Inventory_When_Turn_On to select an item when the inventory menu pop up. It puts the selected inventory item at the center of the screen, but I still cannot select other items in the inventory menu:

    image



    3) Thanks, now I can trigger the interaction with custom key input. 

    To share my findings, I set See Interactions With to Cursor Over Hotspot, Hotspot Detection Method to Player Vicinity, set the Interaction Menu background text to None, and overrided the Interaction icon text the None. So the player can go near the Hotspot, press different buttons to trigger different actions without seeing the interaction menu.


    I am exploring 4) at the mean time. Thank you for your help.
  • The green highlight is an effect set with the default Inventory menu, but only when Adventure Creator is the Source.  When using Unity UI, it's down to the Transition field in the Button component to show a change when an item is selected (assigning an "Active graphic" to an item in the Inventory Manager will also work).

    If the default ShiftLeft / ShiftRight buttons are lighting up then it sounds like you're navigating the menu - just not able to see so.  You should find that your Hotspot label shows the name of the item, so long as the Hotspot menu is beneath your Inventory menu in the Menu Manager.

    The Inventory: Select Action is used to select an item in the sense of having the player ready it to use on a Hotspot - not in the sense of selecting it in the UI.  If you want to do that, you can use the Menu: Select element Action.
  • Finally made 3) worked by unchecking Ignore cursor click? and checked the Pause game when enable. This applies to other menus such as the Pause menu too.

    But to achieve the custom behaviour I wish, I need to write a custom action that finds the current active Hotspot. I tried to use AC.DetectHotspots.GetSelected(). I did this:

    private DetectHotspots detectHotspots;
    private InventoryManager inventoryManager;
    .
    .
    .
    override public bool CheckCondition ()
    {
    if (detectHotspots.GetSelected ().HasInventoryInteraction (inventoryManager.GetItem (invID))) {
    return true;
    } else {
    return false;
    }
    }

    But it always give Null Reference Exception when the script is called. Do I need to do:

    detectHotspots = something
    inventoryManager = something

    within Start() ? Please advise me what I should put there.


    ------

    During exploration, I have other questions about some functions:

    1. For Menu: Select element is the Element to select = the string "InventoryBox"? And should I put the string of the menu name "Inventory" into Menu containing element?

    2. In MenuElement.ProcessClick, how do I reference an AC.Menu _menu and MouseState? Can you give a simple example?
  • edited February 2018
    But it always give Null Reference Exception when the script is called. Do I need to do:
    detectHotspots = something
    inventoryManager = something
    within Start() ? Please advise me what I should put there.

    Actions aren't MonoBehaviours, so they don't have a Start function.

    The Player's DetectHotspots component can be read with KickStarter.player.hotspotDetector, and the InventoryManager with KickStarter.inventoryManager.

    For a general guide to accessing AC components and scripts, see the front page of the scripting guide.


    For Menu: Select element is the Element to select = the string "InventoryBox"? And should I put the string of the menu name "Inventory" into Menu containing element?

    That's correct, it should be the names of the Menu and Element as they appear in the Menu Manager, similar to how the Menu: Change state Action is used.


    In MenuElement.ProcessClick, how do I reference an AC.Menu _menu and MouseState? Can you give a simple example?

    In what context?  Are you modifying the MenuElement script?

    A Menu reference can be gotten with the PlayerMenus.GetMenuWithName() static function - see the "Menu scripting" chapter of the Manual.

    The current mouseState can be read with KickStarter.playerInput.GetMouseState().
  • Thanks. 3) now works as planned

    This leaves the final issue of 4). I am thinking that when the Player choose the Use interaction on a Hotspot, a menu of different options will pop up, and the options will execute different action lists. I am considering 2 methods of doing this:

    Method 1:
    Make use of the Conversation system. But can I put a picture or even an animation beside each Conversation choice?

    Another thing is, when I chose the Conversation Menu Position to be On Hotspot, the menu is not really on the Hotspot. I can't figure out a rule of where it would appear either. Is it a common mistake?

    Method 2:
    Build a custom menu that can show different options, which would looks like the conversation menu but with a graphic or an animation beside each option.


    Which method do you think is feasible? Or are there better ways than what I thought?

    Thanks
  • edited March 2018
    Unless this is to be a sub-menu within a larger Interaction menu, I'm not sure of the need to rely on Conversations, since choosing from a list of icons is what "Choose Hotspot Then Interaction" mode is all about.

    What's the difference (in functionality) between what you're after and the way interactions work in the 2D Demo?  Interaction icons can also be animated - see the Walking Dead template package available on the Downloads page.

    But Conversations can certainly be used if desired.  You can define an associated icon for each option within the Conversation's Inspector, but you'll have to configure your Conversation menu's DialogList element to be able to display them.

    What is your Conversation menu drawn with?  If Adventure Creator, the position will be relative to the small circle that appears in the centre of the screen when previewing it.  If Unity UI, the position will be set to the centre of whatever your RectTransform boundary field is set to.
  • The reason is I hope each Hotspot has a different set of interactions. If I use the Interaction Menu, would it be that I have to create a new Interaction Menu for each Hotspot? 

    And I also hope the custom interactions to be within a next layer after choosing the Use option, which is 1 layer "deeper" than the Use, Talk, Look At choices. So I think I am kind of looking for a sub-menu. In this case, is Conversation Menu the best choice available by default?

    Is it possible to duplicate the Conversation Menu and change its style, so I can use the default Conversation Menu for real conversation, and the changed style menu for custom interactions?

    ---

    About the icons associated with the dialog list or the Hotspot icons, can I use Animated icons?
  • Creating a separate Interaction menu for each Hotspot should not be necessary.  Interaction menus are dynamic - by default, they'll only show icons mapped to interactions available on the Hotspot.  Again, see the 2D Demo - the interface is simple, but doesn't show e.g. the Talk icon when interacting with the Tree.

    To create a sub-menu, yes, you could use a Conversation menu, and have each of the choices listed as a dialogue option.  If you have two Conversation menus, and want to swap out the "active" one at runtime, you can use the Menu: Change state Action to lock one and unlock the other.

    Another way to do this, however, would be to place the "sub interactions" in an invisible Hotspot that's a child of the main one.  When the top-level choice is made, you can then run the Hotspot manually so that these second-level interactions become available.  Currently this is a case of calling the PlayerMenus script's EnableInteractionMenus method:

    AC.KickStarter.playerMenus.EnableInteractionMenus (myHotspot);

    Which is a little tricky because you'd have to place that in a custom Action.  However, I shall modify the Hotspot script as part of the next update to include a function that you can call via the Object: Send message or Object: Call event Actions without need for any custom scripting.

    Interaction icons can be animated, but Conversation icons cannot.
  • If I use the Interaction Menu to serve the prupose, does it mean the interactions from all the Hotspots will be included in the Interaction elements list?

    If so, I think using the Conversation Menus is easier to handle, as it organizes the actions separately for each Hotspot.

    But is there a way to construct a custom Unity UI Conversation Menu that allows an animation icon beside the text?

    ---

    I was also struggling to solve another problem. I am using direct control with Manual Motion Control, and switch to Automatic Motion Control with:

    if (AC.KickStarter.stateHandler.IsInGameplay ())
    {
        canControl = true;
        AC.KickStarter.player.motionControl = AC.MotionControl.Manual;
    }
    else
    {
        canControl = false;
        AC.KickStarter.player.motionControl = AC.MotionControl.Automatic;
    }

    But then I cannot make the Player walk to a marker in game. It works in cutscenes when the gameplay is paused, but this complicates things if I use a cutscene every time I want the Player to walk to a marker. Is there an API to return a boolean of whether the Player is assigned a marker? Or other methods to solve this?

    Thank you
  • Please try to keep separate questions in separate threads to make it more searchable by future users.

    If I use the Interaction Menu to serve the prupose, does it mean the interactions from all the Hotspots will be included in the Interaction elements list?

    I don't understand your meaning.  Interaction elements are not tied to any particular Hotspot, but the icons defined in your Cursor Manager.  If an Interaction menu is enabled for a particular Hotspot, then it'll show elements that are linked to the icons that the Hotpot has interactions for.

    But is there a way to construct a custom Unity UI Conversation Menu that allows an animation icon beside the text?

    I will be considering adding this feature as an update, as it is a good suggestion.  In the meantime, or otherwise, you could feasibly do it by using Unity UI to construct your Menu, and running a custom script to set up animations based on the Conversation it is opened for by hooking into the OnStartConversation custom event.

    Is there an API to return a boolean of whether the Player is assigned a marker? Or other methods to solve this?

    Characters aren't assigned to a Marker, but are registered as pathfinding:

    AC.KickStarter.player.IsPathfinding ();

    Whether you need to use this or not depends on how you control the player.  If it's your own "Direct movement" style, then you probably will.  If it's instead target-based e.g. "Point And Click", then you can instead read the character's GetTargetPosition vector, as covered in this tutorial.
  • edited March 2018
    I don't understand your meaning.  Interaction elements are not tied to any particular Hotspot, but the icons defined in your Cursor Manager.  If an Interaction menu is enabled for a particular Hotspot, then it'll show elements that are linked to the icons that the Hotpot has interactions for.

    Say, I have 50 Hotspots in the game, and each of them has 3 choices in average. If no choices are the same, there will be 150 interactions in total. I am thinking I may confuse myself if all 150 different interaction elements are inside the Interaction Elements list under the Interaction Menu...is my understanding correct?


    I will be considering adding this feature as an update, as it is a good suggestion.  In the meantime, or otherwise, you could feasibly do it by using Unity UI to construct your Menu, and running a custom script to set up animations based on the Conversation it is opened for by hooking into the 
    OnStartConversationcustom event.

    Hmm, may I ask when would you plan to add this update? If you would add this feature it would be super great! And since your implementation is probably better than mine, it may be a better solution for me to wait if it is not too long "^_^


    By the way, a related finding is that, between the Conversation Menu fades out and the Speech Dialog fades in, there is a short moment the player can be controlled, Is it an intended design? I personally think it might feels more natural if the the player cannot move until the dialog is finished. Currently I stop the control during that moment using a global boolean variable.
  • I am thinking I may confuse myself if all 150 different interaction elements are inside the Interaction Elements list under the Interaction Menu...is my understanding correct?

    If by "choice" you mean each Hotspot has unique verbs, then yes - unless you resorted to custom scripting to alter the verb's label / texture before opening the Interaction menu.  If the same verb is shared between Hotspots, then they only need to be listed once in the Cursor Manager.

    Hmm, may I ask when would you plan to add this update? If you would add this feature it would be super great!

    I can't pin myself down on a release date, but I will be adding this in the next update.

    between the Conversation Menu fades out and the Speech Dialog fades in, there is a short moment the player can be controlled

    This is a known bug, and will also be addressed in the upcoming update.
  • Thanks. I think my best option is to wait til all the Hotspots options are finalized XD
  • edited March 2018
    Thanks so much for adding the animated icon support to the Conversation Menu :)

    I found the option, but not exactly know how to use it. Actually I found I cannot get a conversation icon to display after setting it in the Dialog option inside the inspector.

    Am I missing some obvious settings?


    By the way, this issue still persist, not a really big problem though:
    By the way, a related finding is that, between the Conversation Menu fades out and the Speech Dialog fades in, there is a short moment the player can be controlled.
    • Am I missing some obvious settings?
    There is a separation between the properties of a Conversation and the way in which it is displayed.  To have your Conversation icons appear, you must select your Conversation menu in the Menu Manager and set the DialogList element's Display type to Icon Only or Icon And Text.
    • between the Conversation Menu fades out and the Speech Dialog fades in, there is a short moment the player can be controlled.
    Are you using individual DialogList ActionLists for your dialogue responses, or are you overriding them in a single ActionList via the Dialogue: Start Conversation Action's Override options? checkbox?  Also, are any ActionLists set to run when either your Conversation or Subtitle menus are turned on or off?
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.