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
0
Question by dhfijhgky · Jan 14, 2014 at 11:07 PM · inputcontrollerjump

Setting multiple jump buttons

I'm working on a project that uses a gamepad. Currently, the left joystick controls movement, the right joystick controls the camera, and the X or A button is jump.

The issue is that I want to set multiple buttons to jump. Ideally, I'd have a clean way to make every button besides the joystick execute a jump.

I have tried Input.GetButtonDown, Input.GetKeyDown, and Input.anyKeyDown and checking the output against my movement keys and executing a jump on a false return, but it doesn't seem to work that way. I can't compare output to KeyCodes because it's a string, and when I try to compare to strings it spits out this error:

 UnityException: Input Key named:  is unknown

I've also tried adding more keys to my "Jump" input, but it can't seem to handle more than one button at a time.

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

3 Replies

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

Answer by dhfijhgky · Jan 15, 2014 at 03:02 AM

I was overthinking it. By just changing this:

 if(Input.GetAxis("Jump"))

to this:

 if(Input.anyKey)

Any controller button presses are registered and joystick movement is ignored. The only side effect is that it's impossible to move with a keyboard without jumping, but that's fine for what I need. Thanks for the help.

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

Answer by ccwiegreff · Jan 15, 2014 at 12:07 AM

go to the CharacterMotor or FPSInputController script and change the input button to whatever you desire

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

Answer by jhart08 · Jan 15, 2014 at 03:20 AM

Go to Edit > Project Settings > Input. Add 2 more inputs, name both "Jump", and set the Positive Button to "joystick button 0" and the other to "joystick button 2" (look here http://wiki.unity3d.com/index.php?title=Xbox360Controller for controller layouts).

You also might want to add a 3rd "Jump" input to assign to the space button or something, at least for the sake of testing. Make sure all are "Key or Mouse Button" types, with Gravity and Sensitivity set to 1000, and Dead set to 0.001.

It can handle multiple inputs for the same virtual button just fine, so most likely the problem has to do with one or more of the above things. Make sure you're referring to the correct layout, since it varies by platform.

Then in Update, you can have

 if(Input.GetButtonDown("Jump"))
 {
     //Jump
 }
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

20 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

Related Questions

Getting analog input values from multiple controllers 2 Answers

How do I use controller knob input like mouse position? (New Input System) 1 Answer

Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers

my ball sometimes jumps higher or sometimes not 2 Answers

Why doesn't this do anything? 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