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 evildead9000 · Dec 23, 2019 at 02:24 AM · inputbuttonaxis

A button press is not working unless I also press an axis at the same time.

My void Update() is calling Movement(), and the following code is within it. _all_Taps is displayed on screen, so I can easily verify if Special_1 is pressed.

  bool _is_Special_Pressed = Input.GetButton("Special_1");
 
         switch(_is_Special_Pressed)
         {
           case true:
             _all_Taps = "SP BUTTON";
           break;
 
         case false:
           break;
         }

In my input manager I erased all default Inputs and created three; x-axis, Y-axis, and Special_1.

Special_1 has a positive button named "joystick button 5" Gravity is set to 0 Dead is 0.001 Sensitivity is 1000. Type: Key or Mouse Button. Axis is X Axis Joy Num is Get Motion from all Joysticks.

I think it's all correct. However, when I press Special_1 nothing happens unless I ALSO press either axis. I fairly new to Unity and have no clue as to how I can fix it.

Any help would greatly be appreciated.

Thanks!

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 evildead9000 · Dec 23, 2019 at 05:07 AM 0
Share

I also just realized that I'm receiving an Argument Exception: Input Button Submit not setup.

I tried Googling a solution with no luck. Still searching.

Thanks.

UPDATE: I reset my input settings and restored the Submit, Cancel, etc., so the error went away. I then re-created my Special_1. Still not working. In the drop_down for Axis, I must select X, Y, or a numbered axis, but it's not an axis.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by xibanya · Dec 24, 2019 at 02:19 AM

Is there anything you need to have happen if the button is not pressed? As-is, _all_Taps will be set to "SP BUTTON" when the button press is detected but nothing will ever unset it.

Also, GetButton returns true when the button is held down, not for when it's tapped. For that, use GetButtonDown. Additionally, if you are using C#, there is no need to use a switch statement for a bool, you can just use if.

try replacing that entire snippet with

 if (Input.GetButtonDown("Special_1")) _all_Taps = "SP BUTTON";
 else _all_Taps = "negative condition label";

Also, in case you'd like to rename your input buttons later, it's a good idea to keep the name in one place that you can access everywhere else in your code. so I recommend somewhere in your code (maybe in a class that deals the most with input) put this:

public const string SPECIAL_1 = "Special_1";

A constant can be accessed any time without needing to initialize the class. You don't have to give your constants names in all caps but it's a common convention to do that in C# so that when you see the variable name you know immediately that it's a constant.

Once that's set up, you can poll for that input like this: if (Input.GetButtonDown(SPECIAL_1)) doThing(); and if you change the name of that button later, you just need to update the constant and don't need to hunt through all your code for all the places you've written it. Additionally, if you want to find every place you check input for this button press, you can right click the variable name and select Find All References.

alt text

You can click the items in the list that shows up to jump to that place in code. alt text


screenhunter-4655.png (12.7 kB)
screenhunter-4656.png (16.8 kB)
Comment
Add comment · Show 1 · 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 evildead9000 · Dec 24, 2019 at 05:11 AM 0
Share

Great explanation!

I got it now.

Thank you!!

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

162 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

Use Canvas Buttons as Input Axis 1 Answer

Mouse Button vs Get Button 1 Answer

D-Pad as Button instead of Axis 3 Answers

How to replace input axis keyboard button with touch button? 3 Answers

'GetAxis' is not a member of 'function(): void' 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