Using special input

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
OneManOnMars
Posts: 105
Joined: Tue Apr 05, 2016 9:37 am

Using special input

Post by OneManOnMars »

I have an input issue. I am using world space dialog UI with a continue button on it. I think fairly standard. It does all work but I need to change the input system because the game does run on the Nintendo Switch and on this device the inputs can change during gameplay. If you change from one player to coop mode the controllers get rotated on 90° and you suddenly use the controllers sideways which means that the button mapping is not the same anymore and should be rotated as well.
To solve this I use inControl as a control plugIn. This works fine but not yet for the Dialogue System.
I tried to rework the UIButtonKeyTrigger component and add

Code: Select all

heroCharacter.Input.GetActionButtonState(4) == ButtonState.DOWN /*|| UnityEngine.Input.GetKeyDown(key) || (!string.IsNullOrEmpty(buttonName) && DialogueManager.GetInputButtonDown(buttonName))*/
into the if statement in the Update function to use the trigger with my own inputs. But it only works for the very forst dialogue node. So I can start the dialogue but can not continue it.

I assume that the start of the dialogue is not triggered by this component and therefore is still working. And the changes my changes are simply not working.

Ah, I added the namespace that is needed for the GetActionButtonState and assigned the heroCharacter via the inspector.

So, where do these conversations get initiated? There is a usable and a conversation Trigger with on use on my conversant.

Do you have any idea why my own inputs do now work in the UIButtonKeyTrigger?

Thank you!
User avatar
Tony Li
Posts: 21061
Joined: Thu Jul 18, 2013 1:27 pm

Re: Using special input

Post by Tony Li »

Hi,
OneManOnMars wrote: Thu Aug 09, 2018 5:27 amI have an input issue. I am using world space dialog UI with a continue button on it. I think fairly standard. It does all work but I need to change the input system because the game does run on the Nintendo Switch and on this device the inputs can change during gameplay. If you change from one player to coop mode the controllers get rotated on 90° and you suddenly use the controllers sideways which means that the button mapping is not the same anymore and should be rotated as well.
Please remind me -- Are you using Dialogue System version 1.x or 2.x? And are you using Unity UI Dialogue UI, version 2.x's new Standard Dialogue UI, or a different dialogue UI?

Are you using pre-positioned response UI buttons mapped to controller buttons, like in Telltale games for consoles?

Image

If you are, let me know. You've probably assigned UI Button Key Trigger components to them. I'll describe how to override DialogueManager.getButtonDown() to read from InControl. (It's the same process used for the Dialogue System's Rewired support.)

Or are you using the controller's joystick to navigate response UI buttons?

If you're using the joystick to navigate response UI buttons, Standard Dialogue UI and Unity UI Dialogue UI use whatever input module is on Unity's EventSystem. Since you're using InControl, use the InControlInputModule. It's been a while since I used it; I don't know if it automatically adjusts when you switch to coop mode. If not, you may need to set the InControlInputModule's Left/Right/Up/Down mappings manually.
OneManOnMars
Posts: 105
Joined: Tue Apr 05, 2016 9:37 am

Re: Using special input

Post by OneManOnMars »

Hi Tony,
thank you again for your fast reply. I am using Dialogue System Version 1.7.6_Patch20171016 and Unity UI Dialogue UI. A modified version of your speech bubble prefab in fact. And it is similar to the Telltale games you simply have to press a button to continue the dialogue. And yes I added the Button Key Trigger component. If you can let me know how to override this I am pretty sure this would solve the problem. Incontrol should take care of the different button mapping in coop then.
User avatar
Tony Li
Posts: 21061
Joined: Thu Jul 18, 2013 1:27 pm

Re: Using special input

Post by Tony Li »

Hi,

Add a script to the Dialogue Manager that assigns a function to DialogueManager.GetInputButtonDown. I'll sketch it out below. It's been a while since I used InControl, so it's possible that it might need a little tweaking.

DialogueSystemInControl.cs

Code: Select all

using UnityEngine;
using InControl;

public class DialogueSystemInControl : MonoBehaviour
{
    private void Start()
    {
        DialogueManager.GetInputButtonDown = InControlGetButtonDown;
    }

    public bool InControlGetButtonDown(string buttonName)
    {
        InputDevice device = InputManager.ActiveDevice;
        InputControl control = device.GetControlByName(buttonName);
        if (control != null)
        {
            return control.WasPressed;
        }
        else
        {
            return Input.GetButtonDown(buttonName);
        }
    }
}
When this script is on the Dialogue Manager, Dialogue System input components such as UIButtonKeyTrigger will automatically use InControl. There's no need to adjust UIButtonKeyTrigger itself.
OneManOnMars
Posts: 105
Joined: Tue Apr 05, 2016 9:37 am

Re: Using special input

Post by OneManOnMars »

Thanks a lot Tony. I'll give it a try. I'll let you know when it's working or when other questions should occur.
OneManOnMars
Posts: 105
Joined: Tue Apr 05, 2016 9:37 am

Re: Using special input

Post by OneManOnMars »

Alright, there are more questions:

You said but it on the Dialogue Manager. Does this mean on the same gameobject as the Dialogue System Controller?

Does the script you outline override something in the Dialogue System Controller? I can't check the source code of the DS Controller so its hard to say how this should work together.
User avatar
Tony Li
Posts: 21061
Joined: Thu Jul 18, 2013 1:27 pm

Re: Using special input

Post by Tony Li »

Hi,

Technically you can check the source code by importing the SourceCode.unitypackage into a separate project. It's a hassle, which is why version 2.x ships with plain source code instead of DLLs.

The script can be anywhere. Putting it on the Dialogue System Controller GameObject is a good idea because it will survive scene changes that way.
Post Reply