Forum rules - please read before posting.
Tech questions during the weekend? Drop in on the community Discord channel!

Inventory to close on interaction

HI,

I now have my inventory set to open and close on button click and input toggle, but I want the inventory to also close on Player movement - Walk/Look/Talk interaction. How can I implement this?

Thanks

James
«1

Comments

  • What's your Inventory menu's Appear type set to?

    If the Player Action for your Interactions have Cutscene while moving?, then your Inventory will be hidden if its Appear type is set to During Gameplay.

    Otherwise, you could try a custom script to hook into the OnHotspotInteract custom event to turn the Menu off.
  • Where do i set Player Action to Cutscene while moving? If i currently set my Inventory Appear Type to During Gameplay, it is on all the time. (usually set to Manual, as the player clicks on an inventory button to open and close the inventory)
  • Also, anyone able to help with the scripting? As i wouldn't know where to start. Need Inventory menu to turn off on Player Walk, or when a hotspot is interacted with without an inventory item, ie just cursor not inventory object 
  • A Menu can be locked to prevent it from turning on when its "Appear type" condition is met - this can be done with the Menu: Change state Action or through script.  Right-click the Start game locked off? property label to get an API reference to modify it in script.

    The Cutscene while moving? field will appear if your Player action is set to either Walk To or Walk To Marker.
  • OK, I will see if i can get someone to help me with scripting, as I don't want to have to tick Cutscene wile moving to hundreds of interactions. Thanks
  • Also, I'd prefer the inventory to close on walking anywhere, not specifically when clicking on a hotspot. So, I'd need to know how to affect cursor click, rather than walk to
  • Could i put something in thePlayer script that when char.move inventory menu is to turn off, Open menu is to turn off and Constant menu is to turn on?
  • You don't need to modify AC's scripts - custom scripts on top can do it all:

    if (KickStarter.player.IsMovingAlongPath ())
    {
        PlayerMenus.GetMenuWithName ("Inventory").TurnOff ();
    }

    This is all in the scripting guide.  A guide on implementing custom events can be found in the Manual as well as this tutorial.
  • Great thanks, and how would I implement same action on dialogue and player idle?
  • Plus, what do I attach this to?
  • And menu close on cutscene? tx
  • It's an example snippet, not a complete script.  You could add it to the inside of an Update() function to have it run every frame.

    See the Manual chapter and tutorial on custom events.  Events allow you to run code when AC performs certain tasks, for example - when entering "cutscene" mode (OnEnterGameState) and playing speech (OnStartSpeech).
  • Great thanks. Also.... how do I hide/show a menu element? ie Menu: InventoryBag - Element: Open
  • I've looked at the scripting guide, but am stuck on this:

    PlayerMenus.GetElementWithName ("InventoryBag", "Closed")IsVisible(true);

    Keeps telling me it is wrong
  • And, this isn't quite working either!

    using UnityEngine;
    using System.Collections;
    using AC;


    public class CloseInventory : MonoBehaviour
    {
        void Awake()
        {
            DontDestroyOnLoad(this.gameObject);
    }
    void Start()
        {

        }
        private void Update()

        {

            if (KickStarter.player.IsMovingAlongPath())
            {
                PlayerMenus.GetMenuWithName("Inventory").TurnOff();
                PlayerMenus.GetMenuWithName("Open").TurnOff();
                PlayerMenus.GetMenuWithName("Closed").TurnOn();
                AC.GlobalVariables.SetBooleanValue(239, false);
            }
        }
      

    }

    Keeps telling me Unexpected symbol 'void'
  • Updated with a parenthesis but a host of other errors popped up. I tried my damnedest but I am just not great at coding!
  • Sorry, this is the script that isn't working:

    using UnityEngine;
    using System.Collections;
    using AC;


    public class CloseInventoryStopSpeech
    {

    void CloseInventory(AC.PlayerMenus.GetMenuWithName ("Inventory").TurnOff();
      // PlayerMenus.GetElementWithName ("InventoryBag", "Closed").IsVisible(true);
    //PlayerMenus.GetElementWithName ("InventoryBag", "Open").IsVisible(false);
                AC.GlobalVariables.SetBooleanValue(239, false);){}
        void Awake()
        {
            DontDestroyOnLoad(this.gameObject);
    }

    void Start()
        {
    EventManager.OnStartSpeech += CloseInventory;
        }

        void Update()
      {
      
      }
     
    }

  • Awesome. And finally, how doI turn off a menu element, I have this so far:
    PlayerMenus.GetElementWithName ("InventoryBag", "Closed").IsVisible (true);

    but is is telling me 

    Assets/TMOWM/Scripts/CloseInventory.cs(24,62): error CS1955: The member `AC.MenuElement.IsVisible' cannot be used as method or delegate
  • I did it!

    PlayerMenus.GetElementWithName ("InventoryBag", "Open").IsVisible = false;

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.
Do NOT follow this link or you will be banned from the site!