Page 1 of 1

Call dialogue with 2 different buttons?

Posted: Thu Sep 21, 2023 11:10 pm
by Hereder
Hi!
I've been away for some time and totally forgot how I call the dialogue system.
However, i want to make sure I can call it when I press Cross OR Square.
In this old script that I believe is responsible to actually call the UI to pop up, it sais "Action"
but what is that?

I added both Cross and Square, but its ignoring the cross now... If I remove ethe Square it works with Cross.
That little "Action" text, what is that and where do I change it/Add Action2 so we can use both Cross and Square?

Thanks in advnace!

Code: Select all

using UnityEngine;
using UnityEngine.InputSystem;
using PixelCrushers.DialogueSystem;
using PixelCrushers.Wrappers;

public class DialogInput : MonoBehaviour
{
    public InputMaster controls;

    void Awake()
    {
        controls = new InputMaster();

    }

    void OnEnable()
    {
        //controls.Enable();
        InputDeviceManager.RegisterInputAction("Action", controls.Player.Cross);
        InputDeviceManager.RegisterInputAction("Action", controls.Player.Square);
    }

    void OnDisable()
    {
        //controls.Disable();
        //InputDeviceManager.UnregisterInputAction("Action");
        //InputDeviceManager.UnregisterInputAction("Back");
    }
}

Re: Call dialogue with 2 different buttons?

Posted: Fri Sep 22, 2023 8:37 am
by Tony Li
Hi,

If you want to map an input to Cross or Square, in your input actions asset define an action that maps to Cross or Square. Then register it just once. For example, say you have created an action named "Action" in your input actions asset, and it's mapped to Cross or Square. Then use just one call to InputDeviceManager.RegisterInputAction:

Code: Select all

InputDeviceManager.RegisterInputAction("Action", controls.Player.Action);
It's best to name your actions using abstract concepts like "Action" instead of actual physical button names such as Cross and Square. That way they're not dependent on a specific device. For example, the same buttons on an Xbox controller are "A" and "X". But using an abstract concept, you're not tying the action to a specific device, and it also makes more sense if you allow input remapping (e.g., maybe the player wants to use Cross and Circle to interact).

Re: Call dialogue with 2 different buttons?

Posted: Wed Sep 27, 2023 7:02 pm
by Hereder
Okej, thanks- But in my InputMaster (New Inputsystem of Unity) Im naming them Square, Cross, Circle, etc so I know what button it is on a controller. I then link them to South, West, East etc so it works on all controllers. I find it easier to name them to a playstation controller since Im most familiar with it.

Anyway, What i dont understand is, where does "Action" ("Action - (THIS ONE)", controls.Player.Action) come from? Is it built in inside PixelCrusher? Do both Action have to match each other?

The example you gave, would I have to write ("Cross", controls.Player.Cross); to make it communitcate correctly with my Cross input inside the InputManager?

And one sidenote, In the Dialouge Condition section, how do I make OR statements? I believe there was some guide pixelcrushers.com but I cant seem to find it. I wrote "WhateverFUnction" == True or "WhateverFunction2" == True and "WhateverFUnction2" == True.
Can it mike the or and And?

Thanks!

Re: Call dialogue with 2 different buttons?

Posted: Wed Sep 27, 2023 7:34 pm
by Tony Li
Hi,

There are no built-in input action names in the Dialogue System, including no "Action". You may have seen "Action" in some example somewhere.

I assume you're talking about the Selector / Proximity Selector component, but the same idea below applies to any place where you assign an input action. You can't -- and shouldn't -- set up the Selector to read two different input actions. Instead, define a single input action. For example, you could name this input action "CrossOrSquare" and map it to the Cross or Square buttons. (You can still also have separate "Cross" and "Square" input actions.) Then set the Selector's Button Name to "CrossOrSquare", and register it with the InputDeviceManager like this:

Code: Select all

InputDeviceManager.RegisterInputAction("CrossOrSquare", controls.Player.CrossOrSquare);
Hereder wrote: Wed Sep 27, 2023 7:02 pmAnd one sidenote, In the Dialouge Condition section, how do I make OR statements? I believe there was some guide pixelcrushers.com but I cant seem to find it. I wrote "WhateverFUnction" == True or "WhateverFunction2" == True and "WhateverFUnction2" == True.
Can it mix the or and And?
Yes, you can mix them. I recommend using parentheses to disambiguate them. For example, this:

Code: Select all

(Function1() == True or Function2() == True) and Function3() == True
is different from:

Code: Select all

Function1() == True or (Function2() == True and Function3() == True)
In other words, to use a simpler form:

(a or b) and c

is different from:

a or (b and c)

Re: Call dialogue with 2 different buttons?

Posted: Thu Oct 12, 2023 8:01 pm
by Hereder
ok! Thank you for your reply! I think i undertand now :D

But just to clairfy, where you wrote () Thats where I will have to write Function("Night") == true For example?
So:

(Function1("Night") == True or Function2("MidNight") == True) and Function3("Tired") == True
This means, if its Night OR Midnight, AND character is Tired - We call this next branch of the conversation?

Re: Call dialogue with 2 different buttons?

Posted: Thu Oct 12, 2023 8:07 pm
by Tony Li
Yes.

If a C# method / Lua function takes no arguments, you use (), as in:

Code: Select all

Application.Quit();
If a C# method / Lua function takes one string argument, you pass that inside the parentheses, as in:

Code: Select all

SceneManager.LoadScene("Main Menu");
or:

Code: Select all

Function2("Night")