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 Ekta-Mehta-D · Apr 17, 2013 at 06:12 AM · guiinputmultiplesimultaneous

Simultaneous button presses

Hello

I want to make my two buttons work parallely..

In my case ,,I am having One button which allows my player to move left and right and other is fire button which continuously fire..

PlayerMove Button works with Input.GetMouseButtonDown(0) in Update() and for fire it is GUI button in OnGUI()..

Now i wants to make this two button works togather..

For that i want some ideas.. as i search but did not get anything..

So please help me..

Thanks for your support and advice..

Comment
Add comment · Show 5
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 AlucardJay · Apr 17, 2013 at 08:19 AM 0
Share

Your question is too hard to understand. Submit your code and screenshots to illustrate how your controls work.

avatar image Ekta-Mehta-D · Apr 17, 2013 at 08:58 AM 0
Share

have updated question with code..

avatar image syclamoth · Apr 17, 2013 at 09:07 AM 0
Share

Do you mean you want both buttons to be pressed simultaneously? I'm not sure how you mean to do that if they are both in different places on the screen, unless you expect the cursor to be in two places at the same time.

avatar image Ekta-Mehta-D · Apr 17, 2013 at 09:10 AM 0
Share

yeah right i have kept both of them at diff place.. but at a time,only single button is working even if i press both buttons..

avatar image Ekta-Mehta-D · Apr 17, 2013 at 09:44 AM 0
Share

plz somebody help me out..

2 Replies

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

Answer by Ekta-Mehta-D · Apr 18, 2013 at 10:59 AM

I have solved my problem using touch..

 for(var touch : Touch in Input.touches)
         {
             if(touch.phase == TouchPhase.Stationary)
             {
                 var hit  : RaycastHit;
                    var ray  : Ray = Camera.mainCamera.ScreenPointToRay(touch.position);
                    if (Physics.Raycast(ray,hit))
                 {
                     if(hit.collider.gameObject.GetComponent("ButtonId"))
                     {
                         buttonPressed = hit.collider.gameObject.GetComponent("ButtonId");
                         if(buttonPressed.id == "RightMove")
                         {    
                             MovePlayerRight();
                             Debug.Log("right");
                         }
                         if(buttonPressed.id == "Fire" && Time.time > nextFire)
                         {    
                             nextFire = Time.time + fireRate;
                              HandleBullet(); 
                         }
                         if(buttonPressed.id == "LeftMove")
                         {    
                             MovePlayerLeft();
                             Debug.Log("left");
                         }
                     }
                 }
             }
         }

Now my player moves also and fire also parallely on button touch/press.. This all i want to do..

Thanks..

Comment
Add comment · Show 3 · 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 Ekta-Mehta-D · Apr 18, 2013 at 11:01 AM 0
Share

Both actions work togather..

avatar image AlucardJay · Apr 18, 2013 at 11:21 AM 1
Share

Nowhere in this question do you mention touch. This issue was raised in one of the comments :

Do you mean you want both buttons to be pressed simultaneously? I'm not sure how you mean to do that if they are both in different places on the screen, unless you expect the cursor to be in two places at the same time.

The fact that you are using a touch input is essential information to answering your question. Please write better questions in future, include all the relevant information.

avatar image Ekta-Mehta-D · Apr 18, 2013 at 11:24 AM 0
Share

ohk sir.. next time i will take care..but i was not knowing this thing can possible through touch.. but i tried and i got my result.. its ok.. you are right.. i will be careful next time.. and sorry..

avatar image
0

Answer by Linus · Apr 17, 2013 at 10:36 AM

Use a boolean variable and set it to true when button 1 is pressed. Then do a check in the second button detection code to see if the first one is pressed.

Remember to reset it to false when appropriate

Comment
Add comment · Show 3 · 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 Linus · Apr 17, 2013 at 10:39 AM 0
Share

In your example, you will need to find out what is triggered first. The button or the mouse down, some debug log testing should tell you that.

avatar image Ekta-Mehta-D · Apr 17, 2013 at 11:12 AM 0
Share

ok.. I am trying..

avatar image Ekta-Mehta-D · Apr 17, 2013 at 11:43 AM 0
Share

i have tried but still not getting the result..

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

14 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

Related Questions

reading user's keyboard input inside a GUI Input field and saving it into variables for later use? 2 Answers

Simultaneous touch inputs do not always work 0 Answers

Input.mouse position on GUI Textures 2 Answers

Making GuiButton trigger on ps3 controller input 0 Answers

Touch Input with GUI Texture 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