Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 $$anonymous$$ · May 26, 2014 at 11:13 AM · secondsratioclicks

Clicks per second in realtime

Hi all,

I'm making a simple game where you need to click as faster as you can to keep the player's velocity. I'd like the player to know his click ratio (number of clicks he is able to do per second) in realtime before he reach the goal but I don't really know how to approach the solution.

Could somebody give me a tip?

Thanks!

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Shadowys · May 26, 2014 at 11:21 AM

You can use Input.GetMouseButtonUp to get the clicked event and record the clicks into a variable.

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 Lovrenc · May 26, 2014 at 11:22 AM

Have a variable that collects the clicks (every time user clicks, increase it by one). Remember interval start time: long startTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;

Now you have what you need. If you want to refresh the APM every second, you take current time, subtract startTime and see if 1 second has passed. If it did, return the counter and restart the process.

[1]: http://msdn.microsoft.com/en-us/library/system.datetime.now(v=vs.110).aspx

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 $$anonymous$$ · May 26, 2014 at 04:08 PM 0
Share

Hi Lovrenc

What do I get exactly with long startTime = DateTime.Now.Ticks / TimeSpan.TicksPer$$anonymous$$illisecond?

avatar image Lovrenc · May 26, 2014 at 05:22 PM 0
Share

Current time in milliseconds. Also, these things are easy to try and see..

avatar image $$anonymous$$ · May 26, 2014 at 09:46 PM 0
Share

Thanks mate, I'll try it!

avatar image
0

Answer by brettcooperr · Dec 20, 2021 at 03:24 AM

Hello,

One way to approach this would be to use a time-based sampling rate. This means that you would calculate the player's click ratio at fixed intervals, and then display it to the player in real-time.

Another option would be to use a frame-based sampling rate. This means that you would calculate the player's click ratio at the start of every frame, and then display it to the player in real-time.

Which approach you use will depend on your game's specific requirements. Whichever approach you choose, make sure that you are accurately measuring the player's click ratio. This means taking into account things like lag and latency.

You can see how clickspersecond.com is worked on the same principle. It samples the mouse position at a fixed rate and then calculates the number of clicks that were made in between those samples.

I hope this information is helpful! Thank you for your question.

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

23 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

Related Questions

Loading A Level After 40 Seconds 2 Answers

One of the numbers as Second ? 1 Answer

why the debree timer float not work 1 Answer

Viewport ratio appears inconsistent in 2D game 1 Answer

How to change the size/ length ratio between target image and 3D model 0 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