- Home /
Detecting type of joystick/controller for player 1
I was a little confused on how to properly detect the type of controller that is plugged in for each player. Particularly player 1.
I feel like there would be conflicts mapping controller inputs due to the different axis that each controller uses.
For example,
A playstation controllers axis would be different than an xbox controller. Within my code, if i were to code for the xbox controller and configure all of the axis/buttons, it seems like there would be overlapping but different axis for the playstation controller.
I could be thinking about this completely wrong but it seems like you would have to distinguish which type of joystick is being used and use a conditional statement within the code for the controls.
I appreciate any sort of help. Thanks in advance.
Answer by James2Games · Feb 07, 2017 at 08:52 PM
When it comes to controlls it's best to use the Input manager to avoid hard coding each of the buttons and for different devices.
However there have been problems with unity when it comes to xbox controllers such as joysticks control multiple players at random. There is a plugin you can download called XInputDotNet that can help you manage each players controller.
I must've phrased this incorrectly. I am using the input manager. I am confused on how to configure for different controllers for the same player. For instance, if player one goes from using a playstation controller to a xbox controller. The joysticks/axis would be different
Axes do not change, if the controllers input adheres to the standards then a simple
float vertical = Input.GetAxis("Vertical") * (Time.fixedDeltaTime * speed);
would work for an Axis.
The mappings for joystick axis change depending on the controller type. For example, a xbox controller vs. a playstation controller mappings.
Your answer
Follow this Question
Related Questions
Virtual joystick in the new input system 0 Answers
Is there a way to temporarily disable an inputmanager axis through script? 1 Answer
Touch inputs on a Desktop type device 2 Answers
Problem setting up twin stick shooter for mobile device... 1 Answer
how can I assign and use different controller schemes for a single keyboard? 0 Answers