Search code examples
unity-game-engineinput

'Input' is an ambiguous reference between 'UnityEngine.Input' and 'UnityEngine.Windows.Input' error


I just updated the VS and I have this error:

('Input' is an ambiguous reference between 'UnityEngine.Input' and 'UnityEngine.Windows.Input')

Here's the code snippet I got the error at:

float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");

I tried changing the code to UnityEngine.Input but it did not help.


Solution

  • The error most probably appears because you have the following two lines at the top of your file:

    using UnityEngine;
    using UnityEngine.Windows;
    

    The problem lies in the fact that both these namespaces contain a definition for Input.

    As you apparently want to use UnityEngine.Input, you can do one of the following:

    1) Remove the line using UnityEngine.Windows; (but this might induce another problem if you are using things defined in this namespace)

    2) Add the line using Input=UnityEngine.Input; (so there is no ambiguity as to which one you want)