Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Differentiating device used for input in script?

Discussion in 'Input System' started by notMateo, Nov 4, 2019.

  1. notMateo


    Mar 2, 2018
    How can I differentiate between which type of input was used to send the same command? For example I have both mouse delta and right analog stick (on the same player currently) set to the Look Action. I'm trying to make an if statement that basically separates them applies the correct sensitivity.

    Here's a half psuedo-code example of what I'm trying to do.

    Code (CSharp):
    1. public void OnLook(InputValue value, ???? device){
    2.         if (device = Mouse) {
    3.             playerMovement.lookX = value.Get<Vector2>().x * playerMovement * mouseSens;
    4.             playerMovement.lookY = value.Get<Vector2>().y * playerMovement * mouseSens;
    5.         } else if (device = Controller) {
    6.             playerMovement.lookX = value.Get<Vector2>().x * playerMovement * controllerSens;
    7.             playerMovement.lookY = value.Get<Vector2>().y * playerMovement * controllerSens;
    8.         }
    9.     }
    Deleted User likes this.
  2. Jichaels


    Dec 27, 2018
    Use control scheme to do that, it's what I'm doing for pretty much the same reasons (sensitivity and per-device adjustment) and it's working fine. You can know which scheme is used with PlayerInput.currentControlScheme
    Deleted User likes this.