- Home /
Can Input.GetAxis be used without assigning via the Input Manager?
I would like to query input state programatically; the Input Manager in the Editor is pretty much useless in my game.
I can do it already for keyboard/controller keys (via Input.GetKey(KeyCode.Whatever)
), mouse, and touch. But it doesn't seem to be possible to do the same for joystick axes. For example, there's no Input.GetAxis(KeyCode.Joystick1Axis2)
.
I can't find any information on this, but it is the only thing that is missing for me to bypass the Input Manager entirely. I'm perfectly happy to handle input in my own code, and I need key bindings/handling to be flexible. I would prefer not to use other input managers from the Asset Store.
Did I miss something? How can I query axes programatically (i.e. by not using the Input Manager bindings)?
Answer by Sisso · Jun 23, 2015 at 03:07 PM
Answer:
I don't think so.
Workaround:
A engine provide a lot of tools to help you, try to bypass generally cause more frustration that learn how to use. Input Manager is how you configure inputs in your game.
Simple add all the inputs that you will need in input manager for each joystick and namely how do you desire, like "Joystick1Axis2".
Later in code you access like Input.GetAxisRaw("Joystick1Axis2") or Input.GetAxis("Joystick1Axis2")
It does seem to be the case that it's not possible, but that is just ridiculous from the engine developers' AND game developers' standpoint. Unfortunately, I really cannot use the default Input $$anonymous$$anager because it does not even allow(!) rebinding keys at runtime (and that's just basic functionality from many commercial games). Also, there are some input methods the Input $$anonymous$$anager can't seem to even handle easily (like using the analog trigger on an Xbox controller as a binary button). Not to mention, it's dreadful having to set up bindings that way for each button of each of the 4 controllers in a multiplayer game.
Yes, it is very outdated. This Input$$anonymous$$anage come from the first versions, Input are complex and difficult to find a soltion for everybody, so nobody touch it anymore :P
Think it as a bootstrap or data configuration (like specify that joy1 is the same input that keyboard). But you need to do everything else you do in your own Input layer, like probably you are already doing, simple need to add the joystick axis.
Boring? For sure, but is 10 $$anonymous$$utes lost one time.
one time for every game, there is not even a way to copy+paste the input and make it a standard to use in all games, that is exactly why i was making a custom input in the first place, to allow players to make as many different settings as they want
Yeah, I guess setting up all the axes (but not other keys) at the Input $$anonymous$$anager is the solution right now. What does every Input $$anonymous$$anager from the Asset Store do? Use external DLLs? I've seen some that do not support all the platforms we're running the game in. That should ideally come from the Unity developers themselves. (Well, if they had just added that one little function, there'd be no headaches now, at least for me)
I never use one of them. But I think that they could directly access low level API to bypass unity.
Your answer
Follow this Question
Related Questions
C# HUD axis button display 0 Answers
Detect Gyroscope's rotation around a single axis? Like a car game. 0 Answers
Distribute terrain in zones 3 Answers