Input Management

Input Management - Efficiently handle input for Convai's Unity plugin integration.

Make sure that Active Input Handling in

"Project Settings > Player" is set to Both or Input System Package (New).

Our recommendation is Both. This way, you can use both the new and old input systems. Using the old input system can be faster when creating inputs for testing purposes.

How to Change the Talk Button or Any Input?

  1. Click on the "Convai Input Manager" object in your scene.

  1. Find the Input Action you want to change in the Inspector. If you want to add a new Input Action, refer to this documentation. In this case, we selected "Talk Key Action" to change the talk button. Double-click on "T [Keyboard]".

  1. In the opened window, click on the " T [Keyboard " button in the Path field.

  1. Press the " Listen " button in the top left of the opened window. If you prefer, you can choose your desired input from the categories below.

  1. Press the key you want to assign.

  1. After assigning the desired key, you can see in the Inspector that the input for " Talk Key Action " has changed.

How to Add a New Input Action?

  1. First, open the " ConvaiInputManager.cs " script. ( " Convai / Scripts / Utils / ConvaiInputManager.cs " )

  2. Create a variable of type InputAction in the field where other InputAction variables are located. We'll create an Interaction Key Action for example.

public InputAction InteractionKeyAction;
  1. In the OnEnable method, you need to enable the InputAction you created.

  1. Now, let's create a method to access this InputAction.

public bool WasInteractionKeyPressed()
    return InteractionKeyAction.WasPressedThisFrame();
    return Input.GetKeyDown(KeyCode.E);

The #if ENABLE_INPUT_SYSTEM preprocessor directive ensures that this #if statement will function correctly when you select either ' Both ' or ' Input System Package (New) ' in " Project Settings > Player > Active Input Handling "

If you select " Input Manager (Old) " for Active Input Handling, the #else statement will work. Thus, in the #else section, we added the equivalent for the old input system.

  1. After applying the above steps, save by pressing " CTRL+S " Make sure you've done everything correctly.

  2. Return to Unity, click on ConvaiInputManager and in the Inspector, you can see the added Input Action. To assign a key to this Input Action, click the " + " button.

  1. In the opened window, click on the " Add Binding " button.

  1. Click the " Listen " button in the opened window and press the key you want to assign or choose the desired key from the categories.

  1. After selecting the desired key, you can see the assigned key under your Input Action in the Inspector.

Last updated