Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 JackWeller2003 · Mar 25, 2016 at 05:54 PM · unity 5buttonstouchscreenbutton trigger eventsbegginer

Button key assignment?

i made a game with wasd. i want it for android without changing code. is there a way to directly assign a button for a key? (e.g. Jump button = space bar or up = w) thanks in advance!

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 Wolfshadow · Mar 25, 2016 at 10:20 PM 0
Share

Is it that hard to just change out key inputs for onmousedown, etc? You probably have already been over this, but I love using onmousedown.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Wolfshadow · Mar 25, 2016 at 10:33 PM

Xpressed = Input.GetKeyDown(KeyCode.X);

So you could do:

 void OnMouseDown ()
 {
  Xpressed = Input.GetKeyDown(KeyCode.X);
 }

This would act as keycode true when whatever button you have is pressed.

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 Wolfshadow · Mar 25, 2016 at 10:34 PM 0
Share

sorry, the code would be:

    Xpressed = Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.X);
     bool Xpressed
     void On$$anonymous$$ouseDown ()
     { Xpressed = Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.X);
     }

avatar image JackWeller2003 Wolfshadow · Mar 26, 2016 at 09:29 AM 0
Share

thanks! :)

avatar image Wolfshadow · Mar 25, 2016 at 10:34 PM 0
Share

This should work. I haven't tested it yet.

avatar image Wolfshadow · Mar 25, 2016 at 10:34 PM 0
Share

It might need some tweaking.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How can I show words when I tap 3D game objective twice 0 Answers

Unity 5 UI buttons don't respond well with clicks when used in windows standalone with different resolutions. 0 Answers

Unity buttons stopped working on Editor 4 Answers

adding a button/menu to a pop up UI 0 Answers

Door won't go into button slot,My door mesh won't be put into the GameObject script. 0 Answers


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