Forum rules - please read before posting.

Enable and disable single Buttons (InteractionA and/or InteractionB)

Hello,
I have an inventory that opens on input key and I would like to use only interactionB button to check single objects in inventory and disable interactionA (used to combine). Any suggestions on how to do this? I would like to learn more about the possibility of managing AC inputs autonomously and I believe that this problem can be a good start to understand something more.

Thanks so much.

Comments

  • edited April 2021

    AC checks for input using a set of functions that are comparible to Unity's, e.g. InputGetButtonDown in place of Input.GetButtonDown etc. The result of these functions can be overridden through delegates, allowing for conditional input checks.

    See the Manual's "Remapping inputs" chapter for details, but the following example would disable use of the InteractionA input while a Menu named Inventory is open:

    using UnityEngine;
    using AC;
    
    public class ConditionalInputExample : MonoBehaviour
    {
    
        private void Start ()
        {
            KickStarter.playerInput.InputGetButtonDownDelegate = CustomGetButtonDown;
        }
    
        private bool CustomGetButtonDown (string buttonName)
        {
            if (buttonName == "InteractionA" && PlayerMenus.GetMenuWithName ("Inventory").IsOn ())
            {
                return false;
            }
    
            try
            {
                return Input.GetButtonDown (buttonName);
            }
            catch {}
            return false;
        }
    
    }
    
  • Thank you, i've already extended it for more menus, anyway I'll give a look at manual again, probably i'm missing something important like this.

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.