Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411500 Posts in 69373 Topics- by 58429 Members - Latest Member: Alternalo

April 25, 2024, 01:28:58 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Unity - Configuring Gamepad Axes in-game?
Pages: [1]
Print
Author Topic: Unity - Configuring Gamepad Axes in-game?  (Read 792 times)
Bernie
Level 0
***



View Profile WWW
« on: August 21, 2018, 07:34:19 AM »

While it's easy to set up gamepad axes in the Input Manager Unity games come with, I really don't want to use it and am working on an in-game solution. This works pretty well for gamepad buttons and keyboard keys so far, but detecting a gamepad analog stick axis seems to be a problem.

The reason for this is that the axis setup of my no-name gamepad differs from the axis setup of my ps4 controller, so making these customizable would be really good.

My 'if all fails' solution is setting up a few axes in the Input Manager and checking those, but that's kind of a messy way to do this.

The question is, can I detect gamepad axes via scripts without using any 3rd party plugins and without the Input Manager?
Logged

http://www.origamihero.com - freeware oldschool games |  gamedev twitter
bateleur
Level 10
*****



View Profile
« Reply #1 on: August 22, 2018, 03:05:07 AM »

I don't know of a way to avoid using Input Manager entirely, but you can solve the specific problem you describe by using Input.GetJoystickNames and then altering config based on the results.
Logged

Bernie
Level 0
***



View Profile WWW
« Reply #2 on: August 22, 2018, 04:49:45 AM »

Thanks! You're right, there aren't really any other options. I'll make it automatically set the gamepad analog stick axes by default with the GetJoystickNames function and add a way to optionally set them manually for when that fails. It seems like only the first 5 axes are ever used by the analog sticks, making it not too much of a chore to code.
Logged

http://www.origamihero.com - freeware oldschool games |  gamedev twitter
Orymus
Level 3
***


View Profile WWW
« Reply #3 on: August 25, 2018, 07:11:06 AM »

As a side note, Unity is giving access to its new experimental input system as part of its 2018 cadence. You might want to take a peak if you, like most, are unsatisfied with the previous Input manager.
Logged
Bernie
Level 0
***



View Profile WWW
« Reply #4 on: August 25, 2018, 06:06:26 PM »

It's good that they're finally tackling that. I'm staying on version 5.6 deliberately for my current game, but I'll keep it in mind for future projects.
Logged

http://www.origamihero.com - freeware oldschool games |  gamedev twitter
Orymus
Level 3
***


View Profile WWW
« Reply #5 on: August 31, 2018, 04:02:52 AM »

The new Unity module for input, I believe, is standalone, so in theory, it may be backwards-compatible.
That being said, I don't think it goes further back than 2018.1 or something.
Oh well!
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic