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 ahmad-hadia · Jun 28, 2017 at 05:57 PM · scipting

more than one key to do something

hello ,i want idea when i create game , i want more keys to do type hit,street fighter method press s then a then d to do animation

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 tanoshimi · Jun 28, 2017 at 06:18 PM 0
Share

So, what's stopping you? You have not asked a question.

4 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Trevdevs · Jun 28, 2017 at 07:15 PM

Lets have a lesson. please try at least doing a google search before you ask a question next time.

Input.GetKey() Means if such a key is being held https://docs.unity3d.com/ScriptReference/Input.GetKey.html

Input.GetKeyDown() Means if such a key is pressed https://docs.unity3d.com/ScriptReference/Input.GetKeyDown.html

I've never played street fighter but if it goes something like where you HOLD s and HOLD a then press d is does something different or if its you press every key at the same time

HOLD s HOLD a PRESS d

 if(Input.GetKey(KeyCode.S)) //S is being held
 {
     if(Input.GetKey(KeyCode.A)) //A is being held
     {
         if(Input.GetKeyDown(KeyCode.D)) //D is pressed
         {
             //do something...
         }
     }
 }


PRESS s PRESS a PRESS d

 if(Input.GetKeyDown(KeyCode.S)) //Pressing all 3 S A D keys at the same time
 {
     if(Input.GetKeyDown(KeyCode.A))
     {
         if(Input.GetKeyDown(KeyCode.D))
         {
             //Do something
         }
     }
 }
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 DominikKin · Jun 28, 2017 at 07:20 PM

Wouldn't combining it make more sense? Is there a difference to these 2? Only asking as a newb

 if(Input.GetKeyDown(KeyCode.S) && Input.GetKeyDown(KeyCode.A) && Input.GetKeyDown(KeyCode.D) )
 {
 //Do something
 }
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 Jwizard93 · Jun 29, 2017 at 03:57 PM 0
Share

I think it's really a matter of preference here. The behavior is the exact same. When you '&&' conditions together the control exits the tests once the first false is found. (this is good if you want to test (object != null && object.something == x), saves you from an error when object is null. So it's the same as the nested example. I like your example better, though. it just looks cleaner to me.

avatar image
0

Answer by Jwizard93 · Jun 28, 2017 at 09:06 PM

Build a Moore type Finite State Machine. Example:

When nothing has been pressed you are in state 0. If you press 'A' you are in state 1. If you now press 'B' you go to state 2 which triggers the AB combo. If from state 1 you press 'C' then you go to state 3 which triggers the AC combo. It's as complex as you make it. Make sure to return to state 0 eventually or if you press a key not part of a combo.

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 ahmad-hadia · Jun 29, 2017 at 10:38 PM

thanks all , in this time i do not want to make game like this ,it is fighter game , and more than 30 move list ,so must have more keys,but i know i have it in unity , thanks again for all

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

69 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

Related Questions

Change Color of a Emission Texture 0 Answers

Tons of Scripts, Doing Small things to game. Performance issuses in future? 1 Answer

Confused on Coroutines and/or For Loops 1 Answer

Compiler Error List Archive Solutions 1 Answer

Faulty 'unused' errors in vscode for `Update` and `Start`? 3 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