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 P_N · Oct 06, 2014 at 11:08 PM · inputupdate

How do I check for input that is faster than 1 frame?

I am having the player jump on hitting the jump button and slow down on releasing the button. This works great, unless the button is pressed faster than a single frame, so the question is how to check if the button has been pressed and released in between two update calls.

Comment
Add comment · Show 8
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 awest · Oct 06, 2014 at 11:51 PM 0
Share

I don't think what you're asking is possible, but I would recommend trying

 if (Input.GetButton("Jump")) {..jump and set grounded false..}
 else if (!grounded) {..slow..}
avatar image P_N · Oct 07, 2014 at 12:46 AM 0
Share

This still does not register button presses that are shorter than 1 frame, so even though I hit the jump button nothing happens.

avatar image Tepei · Oct 07, 2014 at 12:59 AM 0
Share

Is the button not registered or maybe the slow down that hide the effect of the button ? $$anonymous$$aybe try If (input.GetButton("Jump")) Debug.Log("buttonjump"); to see if it register..

avatar image awest · Oct 07, 2014 at 01:09 AM 0
Share

There must be something else going wrong here. Detecting jump in the Update function is standard. I'd make sure that it is indeed listening for the input every frame, that there is no conflicting code, and that frame rate is well above 30fps.

If that's good then perhaps enter a fast clicking competition!?

avatar image P_N · Oct 07, 2014 at 01:20 AM 0
Share

That is all working, framerate at 50 etc; but if i hit the jump button and release it both inbetween update calls it will not register at all. So I guess there is no way to check if input has happened since the last update, is there maybe a way to have something that checks considerably faster than update?

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by guavaman · Oct 07, 2014 at 04:10 AM

If I understand your issue correctly, the game is running at a low frame rate and you are unable to detect input when the button press duration is less than the current frame rate. The only real solution to this is to decouple the input from the graphics update. Unfortunately, this is not possible using Unity's input system. Unity updates input only in the Update loop, so even if you get input in the FixedUpdate loop, that input is really only updated once per Update, meaning the input data is not refreshed necessarily every FixedUpdate when the frame rate is low.

There is a way around this problem, but it requires you go outside Unity to a native library to get your input. My input system Rewired does exactly this on Windows, Windows Store, and OSX. (Other platforms are supported but do not allow for framerate-independent input yet.) It refreshes the input information in the FixedUpdate loop which will be updated at the rate specified by the fixed timestep in Time Manager in Unity. By default, this is 50 fps, but you can increase that update rate further. When you get input in FixedUpdate or by using event-based input, you can get input at a constant rate even when the graphics slow down.

At present, there is a limitation however, in that Rewired does not use the native libraries for keyboard or mouse input. This may change in the future, but for now only joysticks and Custom Controllers (used for on-screen touch controls and other such custom input sources) are updated in this framerate-independent fashion.

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 Polymorphik · Oct 07, 2014 at 03:58 AM

Not sure what you are trying do here but you can use FixedUpdate to check if you are jumping then use update to see if they released the button. I think thats the best you can do, but again not sure what you are doing...

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 Tepei · Oct 07, 2014 at 09:27 AM 0
Share

I made some test at 6 fps ... i always have 1 button registered in the update and 8 in the fixed update.

How faster could you release this button ?? You might be so fast that even the keyboard and the computer could not see anything !!!

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Activate an input to pickup or search objectes 1 Answer

New Input system holding down a button 2 Answers

How to have user input behave the same through variable framerates? 1 Answer

Button.onClick.AddListener 1 Answer

How do I pass an input in Update() to FixedUpdate() for Physics movement? 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