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 VPanom · Oct 03, 2016 at 06:00 AM · inputclickmouseclickinput.getkey

Input.GetKey(KeyCode.Mouse0) does not work if any other Buttons is pressed how can i get around this?

I have tried Input.GetButton("Fire1") as well and it still does not work if other buttons are pressed or held at the same time. I am trying to do trigger a shooting animation when i run but i can only get it to work while standing. it does not work even if i hold down an unrelated button that i don't use for anything. here's my code if it helps! And the Debug.Log messages only appears in the console if i am standing still and no other buttons are pressed or held while pressing or holding Mouse0. Oh and i want to be able to click anywhere on the screen not just on specific object! sorry for wall of text and thanks in advance!

 public Animator MyAnimator;

 void Start () {
     MyAnimator = GameObject.Find("GunShotAnim").GetComponent<Animator> ();
 }
 

 void Update () {
     if (Input.GetKey(KeyCode.Mouse0)) {
         MyAnimator.SetBool ("BOOM", true);
         Debug.Log ("ClickDown or held");

     } else if (Input.GetKeyUp(KeyCode.Mouse0)) {
         MyAnimator.SetBool ("BOOM", false);
         Debug.Log ("clickUp");
     
     
     }

 }
Comment
Add comment · Show 4
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 Mindmapfreak · Oct 03, 2016 at 08:49 PM 0
Share

This works on my computer ... I tried holding down keyboard buttons and mouse buttons and it works as expected in both cases. Does it make a difference if you remove the $$anonymous$$yAnimator stuff?

avatar image VPanom Mindmapfreak · Oct 03, 2016 at 09:43 PM 0
Share

Nope it doesn't make any difference at all.. but i should maybe add that i am not using a real mouse, I am using my Laptops mouse-pad when trying it out. I think that might screw something up in the Input.. I'm going to buy a mouse and try that out. Thanks for your help and time!

avatar image Mindmapfreak VPanom · Oct 04, 2016 at 12:18 PM 1
Share

I also tried it with my mouse-pad, that works too. Seems like something specific to your laptop ...

Show more comments

2 Replies

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

Answer by VPanom · Oct 04, 2016 at 09:31 PM

Hey everybody that follows this question and or have the same problem and stumbles upon this post! The issue seems to be in my computer. I connected a real mouse and everything works just fine now. I have previously used the mouse-pad. My laptop brand is an Asus X555L, If that helps anyone that is experiencing the same kind of issue! Happy coding, Best regards Victor!

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 AurimasBlazulionis · Oct 03, 2016 at 09:00 PM

You can also use Input.GetMouseButton. That should really work. If it does not, then it might be something wrong on your side. Also, if it does not, try it in build, sometimes some editor extensions block things.

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 VPanom · Oct 03, 2016 at 09:44 PM 0
Share

Nope it doesn't make any difference at all.. but i should maybe add that i am not using a real mouse, I am using my Laptops mouse-pad when trying it out. I think that might screw something up in the Input.. I'm going to buy a mouse and try that out. Thanks for your help and time!

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Differentiate left, right and both mouse inputs 0 Answers

Two buttons (Quads) are not working at a same time. 2 Answers

How to check which key i have pressed? 3 Answers

Raycast hit not detected on cube 1 Answer

Disable mouse input and cursor in game 2 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