- Home /
What is the command to use a joystick in the Input Manager?
Hi, I am creating an iOS game that uses a joystick for the third person to move with animation. I have scripts and animations for the character. It works great with the arrow keys but I can't find the actual word or words to use to make the horizontal and vertical movement work with the joystick for iOS in the input manager. I have tried joystick button 0, joystick 1 button 0, I have set up separate axes for the joysticks, I have even tried it with character prefabs supplied by Unity just in case there was a problem with my prefabs. Nothing works. I can get everything to work with the mouse buttons, any keyboard button, or even just mouse movements but not with joysticks. All the commands are put into the horizontal and vertical axes in the input manager. If you know the commands for the joystick prefabs, please tell me. Thank you so much. Tom
Answer by drex150 · Jul 20, 2014 at 11:20 PM
I'm not 100% sure if this is what you're looking for, but let me know!
As long as you haven't modified the inputs located in Edit > Project Settings > Input they will be their defaults.
To access the defaults you use: Input.GetAxis("Horizontal") and Input.GetAxis("Vertical").
If you look at the list of inputs, you will notice that Horizontal and Vertical are the names of the inputs. Whatever the name is, is what you put in to your script.
For example: Input.GetButton("Fire1") will be the A button on a joystick, the left mouse click, and the ctrl key. All three of those are set up by default in the input for Fire1.
You should always use the inputs instead of hard coding a key because then it's simple to set up key bindings if you want to. Also it's just easier to remember "Fire1" instead of "Key.Code blah blah" haha.
@drex150, you are exactly right with everything you said. The problem is, I need the exact word used to get the signal from the on screen joystick in iOS. For example, when I go to Edit, Project Settings, Input, I get the axes (which is what you said). Within the axes, there is the "Horizontal" and "Vertical" commands that are in the code that is standard. Within the "Horizontal" and "Vertical" axes, there is the "Negative Button" and the "Positive Button" that controls left and right and up and down. Within those four fields are the defaults of "left" and "right" and "up" and "down" for the arrow keys. What I want to do is replace the "left" and "right" inputs in the fields with whatever the proper word(s) are for using the joystick in the iOS. I have tried the left and right mouse buttons and it worked perfectly. I also tried various letters and numbers in substitution for the arrow keys and they worked fine as well. I just don't know what the command words are for the joystick. If you (or someone reading this) could tell me, I would really appreciate it and possibly save the rest of my hair. Thanks so much for your help so far. $$anonymous$$
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
with a joystick impossible to have horizontal=1 and vertical=1 at the same time 1 Answer
How to detect Double Clicking Horizontal/Vertical Axis on joystick 0 Answers
What is the axis for Controller Triggers? 1 Answer
What is the value of joystick code vertical and horizontal 0 Answers