Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Vroomy · Apr 17, 2013 at 09:45 PM · inputgamepadmappingcontrollers

InputManager, Gamepads, Wheels: remapping and calibrating

My current project will benefit from uniform support for Keyboard, Gamepad, and Racing Wheel, but I am at the mercy of the InputManager and the controllers which map their axes in different ways. I have tested the Xbox Controller, WingMan cordless gamepad, and Thrustmaster Ferrari Challenge Wheel.

Axis X: Steering [is ok]

  • Xbox: Left stick horizontal, InputManager value resting at 0, range [-1,1]

  • WingMan: Left stick horizontal, InputManager value resting at 0, range [-1,1]

  • Wheel: Wheel centered, InputManager value resting at 0, range [-1,1]

Axis Y:

  • Xbox: Left stick Vertical, InputManager value resting at 0, range [-1,1]

  • WingMan: Left stick Vertical, InputManager value resting at 0, range [-1,1]

  • Wheel: Left (brake) pedal, InputManager value resting at 1, range [1,-1]

Axiz Z/3:

  • Xbox: Left Trigger + Right Trigger, (resting at 0, range [0,1])+(resting at 0, range [0,-1])

  • WingMan: Throttle Slider, inverted, range [-1,1]

  • Wheel: Right (accelerator) pedal, InputManager value resting at 1, range [1,-1]

Problem:

For my driving game, Steering is just fine, but I also want values from brake and accelerator in the range [0,1]. The racing wheel's pedals will need to be remapped to more sensible values, given their rest state and range.

Hypothesis:

I expect the solution to involve bypassing the InputManager in some fashion. I could configure the InputManager's axes to allow me access each possible axis. The value would be interpreted during Update() according to the name of the controller detected. This will limit support to those devices for which I code custom mappings. Also, the user will need to have only one controller plugged in at a time.

TL;DR: Is there a GOOD way around the InputManager for mapping and calibrating ANY controller from within the game?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by iwaldrop · Apr 18, 2013 at 04:26 AM

There is an easier way. :)

 void Update()
 {
     float value = Input.GetAxis("LeftVertical");
     value = Mathf.Lerp(0, 1, value/2);
     Debug.Log(value);
 }

EDIT:

I must have been really tired last night when I posted this answer because I was pretty sure I saw it working in the editor. Then I was thinking about it at work today and realized that it couldn't have possibly worked. Sure enough, I got home and found that the equation is fundamentally flawed. This is the closest I can get:

     value = Mathf.Lerp(0, 1, (value + 1) * 0.5f);

Still, it has a margin of error of 0.5, so there is still something that needs to be done to bring it inline with the 0-1 range.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Vroomy · Apr 18, 2013 at 08:01 PM 1
Share

That doesn't exactly address the problem of controllers mapping their controls to different axes, with different values, sometimes even inverted.

I've currently got a wrapper function that interprets correctly for the wheel and xbox controller (it seems to be the popular way), but it is annoying to try getting the Input$$anonymous$$anager to play nice while there's a whole industry of other peripherals out there mapping things slightly differently.

avatar image iwaldrop · Apr 18, 2013 at 08:23 PM 0
Share

Firstly, this should have been a comment not an answer.

Secondly, you're right, it doesn't address different axes. You should use your wrapper to use the axis that the controller uses and detect it at runtime. That's why so many games allow you to either pick the controller that you're using or allow you to calibrate the game. It'll ask you to fully depress the accelerator, then the brake. Essentially, you'll have to map it internally using a class of your own devising.

avatar image Vroomy · Apr 18, 2013 at 08:28 PM 0
Share

(Still finding my way around: pressed the wrong button)

I guess it's resolved then. I was afraid it would come to that.

avatar image iwaldrop · Apr 18, 2013 at 08:31 PM 0
Share

Yeah, sorry about that. But maybe I'm wrong too (it wouldn't be the first time). I hope, for your sake, someone will drop in here and correct me. :)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Mapping multiple controllers 1 Answer

Axis 9 and 10 not working with 2 Xbox 360 controllers plugged in 1 Answer

How to get gamepad for player 2 to control player? 1 Answer

What's the best way to retrieve input from more than 4 controllers ? 1 Answer

How do I standardize my game's input to different types of controllers? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges