- Home /
`Input' does not contain a definition for `GetAxis'
Hello everyone!
I have been a unity3D user for several years now, and I have developed a decent ability with C# scripting inside the engine.
Just recently, I have encountered this error while scripting:
'Input' does not contain a definition for 'GetAxis'
The same goes for any other input definitions.
I have no clue what is wrong. When using MonoDevelop, the only definitions available in Input are those that belong to Object/GameObject.
I am sure that this isn't a problem with any script I have, as it is currently just a copy of an example from the scripting reference, additionally, the script was working fine for several test beforehand.
Any tips would be greatly appreciated!
Answer by Eric5h5 · May 27, 2012 at 02:23 AM
Don't name your classes the same thing as Unity classes. (Well, you can, but if you do that then you have to specify which one you mean every time, which is a bit annoying.)
I haven't been na$$anonymous$$g any custom definitions if that's what you mean. The script was working fine before this happened, and it is not giving errors in any other projects.
Creating a javascript with the name Input would do the same thing, it makes a class called Input.
You made a class called Input, which doesn't have a GetAxis function, so when you say "Input.GetAxis", Unity looks in your Input class and doesn't find any GetAxis function, and complains. You can differentiate by saying "UnityEngine.Input", but as I said, it's better just to not do that.
Ahh, well I'm not doing that either. I haven't made any custom classes. I'm simply calling:
float example = Input.GetAxis("Vertical");
or
bool example = Input.GetAxis("Jump");
which is giving the aforementioned error
To be clear - you haven't made a script called Input in Javascript? It's got to be that or the fact you have created a variable called Input which is of type GameObject.
Answer by arcade82 · Nov 08, 2014 at 03:41 AM
For anybody else, who maybe more recently than 2 years ago encountered this problem. I just fixed mine with: changing float moveHorizontal = Input.getAxis("Horizontal"); to
{ float moveHorizontal = UnityEngine.Input.GetAxis("Horizontal"); }
It doens't recognize the getAxis without a CAPital G and it doesn't recognize the Input without UnityEngine attached.
You would never use getAxis anyway since functions are always capitalized. But yes, doing this is exactly what I said to do in my answer. All of this has already been explained (read the comments).
Your answer
![](https://koobas.hobune.stream/wayback/20220613072006im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to set(raw) 'horizontal' input axis value in script 1 Answer
Why does InputManager have multiple axes with the same name? 1 Answer
How to get overall intensity for each Joystick Axis? 4 Answers
input resets after scene change,Held Down Input not responding after scene change. 0 Answers
How to convert Input.GetAxis to Accelerometer control? 2 Answers