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 Omwro · Oct 26, 2016 at 09:38 AM · script.mysqlcpu usage

help with reducing cpu usage

i have a problem with my script. when i run the game, my gamescript Update() is using a lot of cpu. i tried to reduce it a bit with some methodes but still a lot of cpu. Profiler GameScript

as you guys saw i have an online free database and the database works perfect but it uses a lot of cpu. i tried a methode that Update() only update every second but than you will see every second that some frames freezes. i really dont know how to reduce the gpu usage from my Update() in my gamescript while my script is still working. what this script does = getting data from the database, sums up those data to a total score. and than show the score in a textlabel.(btw i also have a script that is when i get a point it inserts it to the database(thats why i want it in update so the totalscore/highscore will stay updated)). i hope you guys can help me with reducing the script cpu usage or a better methode so i dont have fps lag. thanks in advance.

gamescript.txt (4.4 kB)
unitypic1.png (50.6 kB)
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

1 Reply

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

Answer by OusedGames · Oct 26, 2016 at 01:08 PM

Hello, I am noob about network, but if you are accessing it every frame, it will consume more network data isn't it? So update will cost a lot of network and cpu

  • I think you should get the online total score only on some circumstances like:

  • the game starts/ match starts/ on Game over/ on accessing leaderboard/ on game quit

  • Or run that in every 10 frames or fixed update

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 Omwro · Oct 27, 2016 at 08:34 AM 0
Share

Hey OusedGames, first of all thanks for you reply and also sorry for a late respond. i tried yesterday to follow your 2nd advice. i tried with variables to only refresh it at it at the start of the game and at the end of the game(game over) and it worked. i also tried it on every 10 frames but it froze some other frames but your 2nd advice worked well. thanks for you help here is some example which code i used:

 void Update () {//        REFRESH AT START                                    REFRESH AT DEATH                                   REFRESH AT WIN
         if ((PlayerController.IDied == false && Number == 0) || (PlayerController.IDied == true && Number <= 3) || (PlayerController.IWin == true && Number <= 3))
         {
             Number++;

The Code You Want To Repeat

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

59 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 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 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

the scripts, physics and others execution time increase for low quality compared to good quality 0 Answers

function calls for each frame in the scene 0 Answers

Need help with 24 Hour timing script. 1 Answer

"getcurve" from a gameobject 0 Answers

two sided card that changes when flips 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