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
1
Question by oliver-jones · Jan 23, 2011 at 11:59 AM · inputoncerepeatgetbuttonnon

Prevent 'Hold' Of A Mouse Click

Hello,

I have a veryy simple script that basically says when Fire1 is pressed, play Fire animation (recoil of a pistol) - and it works very well. The thing is, if I were to hold down the mouse button, my pistol turns into a fully automatic death machine.

Is there a way to prevent the 'hold status' of a mouse button - so the user has to keep clicking in order to fire instead of just holding it down - maybe within 2 seconds of each other?

I'm sure this is a easy solution and apologies if it has been repeated.

Ollie

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 Chris 35 · Apr 25, 2011 at 07:42 AM 0
Share

im trying to make an automatic weapon how did you make it so when you hold the mouse button it continuously fires ?

2 Replies

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

Answer by AliAzin · Jan 23, 2011 at 12:06 PM

Hi, You can simply use Input.GetButtonDown(). Then you can set a boolean to prevent player from shooting in next two seconds.

Comment
Add comment · Show 2 · 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 oliver-jones · Jan 23, 2011 at 12:07 PM 0
Share

How the hell did I not think of that -- its been a longgg day

avatar image Ralp · Apr 07, 2013 at 02:11 AM 0
Share

And I was breaking my head trying to do that... almost gone mad when found this is so simple!

You can also use if(!animation.isPlaying) to ensure it will only play after the fire animation is complete.

avatar image
1

Answer by FLASHDENMARK · Jan 23, 2011 at 12:08 PM

I assume that it is a easy fix.

Input.GetButtonDown("Fire1")

Only works once, and then you have to release the button and click it again in order for it excute.

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

1 Person is following this question.

avatar image

Related Questions

Input: Mixing axis and buttons (ie: Input.GetAxis versus Input.GetButton) 4 Answers

Press button once to enter vehicle and once again to exit 1 Answer

How can I check if a key/button is not (!) being held down? 1 Answer

Weird Input System situation 1 Answer

How can I use multiple GetButtonDown keys simultaneously? 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