Forum rules - please read before posting.

Adding new inputs with the new Input system

Hi everyone,

I have recently added AC's new input system integration package and wanted to ask about the workflow of adding a new action:

After adding a new action inside the controls asset, how do I get AC talking to this specific file?

Do I also need to reference these inputs in AC's ActiveInputs Editor?

And when I am trying to reference the action inside a C# script, is it better to use

KickStarter.playerInput.InputGetButton("HighlightHotspot")

Or would I create an InputActionReference and subscribe to this reference in OnEnable?

Sorry about the confusion, I think I'm mixing up two different workflows here.

Comments

  • After adding a new action inside the controls asset, how do I get AC talking to this specific file?

    In what way is AC relying on this input? In an Active Input?

    It should just be a case of naming the action the same as the "Input name" field, similar to the way the defaut actions are set up.

    And when I am trying to reference the action inside a C# script, is it better to use

    They should be identical. The only difference I can see is that the first method would still work if you later chose to remove Input System.

  • In what way is AC relying on this input? In an Active Input?

    I'm not sure I follow exactly. The way I understand it, even if I create a new action via the new unity input system, I still need to add that to the active input editor, otherwise there is no way AC and the action can talk to each other - is that not correct?

  • edited April 30

    It is - I'm just checking that it's an Active Input you're ultimately using.

    In the case of Active Inputs, the "Input button" field, set to the name of the new Action, should be enough.

  • ACVACV
    edited April 30

    Right. In my case, I've added two new inputs to rotate game objects left and right. This is all done in a custom script.

     private void Update()
        {
            if (arrangingPuzzlePiece != null && arrangingPuzzlePiece.IsSelected)
            {
                HandleRotationInput();
            }
        }
    
        private void HandleRotationInput()
        {
            if (KickStarter.playerInput.InputGetButton("RotateLeft"))
            {
                RotatePiece(rotationSpeed * Time.deltaTime);
            }
    
            if (KickStarter.playerInput.InputGetButton("RotateRight"))
            {
                RotatePiece(-rotationSpeed * Time.deltaTime);
            }
        }
    
  • In the case of Active Inputs, the "Input button" field, set to the name of the new Action, should be enough.

    Aha! So the standard way to set up an active input would be -> Create the action inside the new unity input system -> Create a corresponding active input with the same name -> reference that active input via Kickstarter.playerInput.GetButtonDown("ExampleInput")?

  • I'm not sure we're both referring to the same thing with the term "Active Input".

    In AC, an Active Input is one listed in the Active Inputs Editor - in which an ActionList will run automatically when a given input is pressed. It is not referenced through script.

    If you are just looking to reference an action you've added to your Input Actions asset, either referencing it as you have above - or with an InputActionReference variable - should work.

  • Thank you for clarifying.

    So Active Inputs always run an ActionList, where as the regular inputs(?) I define via the new unity input system are used for C# scripting - and if I understand correctly, for these it doesn't make a huge difference whether I'm subscribing to an action list reference or check for my action via Kickstarter.playerInput, is that correct?

    I suppose in this case Active Inputs are best used for Actions that can be entirely done via the ActionLists where no C# scripting is required?

  • I'm subscribing to an action list reference

    If you meant "Input action reference", then yes - the key difference being that with playerInput you can just reference the input by name.

    I suppose in this case Active Inputs are best used for Actions that can be entirely done via the ActionLists where no C# scripting is required?

    Right.

  • Thank you for clearing this up, Chris!

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.