Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by amrit88 · Sep 07, 2011 at 12:37 AM · joystickcenterxboxjoypad

Stop The Xbox Joystick Moving From The Centre Position

How can i stop the Xbox joystick moving from the centre position.

i have tried something like this:

 float x = Input.GetAxis("Mouse X Xbox");
    if( x < 0.1  && x > -0.1)
    {
      x = 0;
    }
Comment
Add comment · Show 1
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 aldonaletto · Sep 07, 2011 at 01:15 AM 0
Share

I know nothing about XBox, so I don't have idea if this can apply to your case: I saw a similar question some time ago, and the reason was a "forgotten" device connected to the XBox (both were controlling the same axes). Other possibility: could you have two "$$anonymous$$ouse X Xbox" axes declared in the Input manager, but connected to different devices?

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by formidable · Sep 07, 2011 at 01:12 AM

I think you might be using the wrong operator. Have you tried it with || instead of &&?

Comment
Add comment · Show 2 · 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 aldonaletto · Sep 07, 2011 at 01:59 AM 0
Share

No, the operator is correct: if x lower than 0.1 AND higher than -0.1 then force it to 0; in other words, if x between -0.1 and 0.1, force it to zero.

avatar image amrit88 · Sep 08, 2011 at 10:53 AM 0
Share

anyone got any other solution

avatar image
0

Answer by Ipsquiggle · Sep 07, 2011 at 02:28 AM

I'd start with just doing a Debug.Log() of the value that GetAxis is giving you. The code you posted should do exactly what you want, so my next thought would be bad data. Things that come to mind:

  • The joystick is badly centered, so at a rest position, it is providing a value out of that range.

  • The joystick is old and has a lot of noise in it, so you need to specify a larger dead-zone.

  • There is another input which is mapping to that axis (such as the mouse)

  • The range isn't what you expect (i.e. it's actually 0 to 1, or -100 to +100) so the values provided aren't causing the proper restriction.

Another thing to consider is an error elsewhere. Did you remember to use x later on in the program, or are you still reading from GetAxis directly? etc.

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 amrit88 · Sep 07, 2011 at 10:12 PM 0
Share

i have no errors throughout the application and also i am using the "x" variable throughout the application

avatar image amrit88 · Sep 07, 2011 at 10:16 PM 0
Share

I also checked the joystick value through the debug statement. the xbox controlles uses and value between 0 to 1.

avatar image Ipsquiggle · Sep 07, 2011 at 10:59 PM 0
Share

So if the value is between 0 and 1, then you should be centering at 0.5? I don't have an xbox controller myself to test this with.

Other than that, I'm out of ideas, sorry.

avatar image amrit88 · Sep 08, 2011 at 03:04 PM 0
Share

no porblem Ipsquiggle, thanks for tryin to help

avatar image
0

Answer by DaSquanto · Dec 01, 2016 at 11:47 AM

You are best to utilize the Input Manager and setting the Deadzone to 0.2 (this is usually pretty good for the sticks natural drift), and 0.1 for the triggers if they are giving you an issue.

Comment
Add comment · 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

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

8 People are following this question.

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

Related Questions

How to use a PS3 controller to control an FPS 2 Answers

Basic character movement with joystick 1 Answer

Generic USB Controller axis issue 0 Answers

How many usb joysticks can i connect to a pc? 0 Answers

Joystick DPad axis to bool 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