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 Knoxley · Apr 13, 2013 at 06:55 PM · javascriptiphoneperformanceframeratestutter

Stuttering / performance issue with certain JS scripts

Working on a very simple pong style game, I have two scripts which cause the game to skip / stutter for the first few seconds of the scenes loading up. If I remove these two scripts, the stuttering goes away. It seems to stabilize after 10-15 seconds and only happens when the level first starts. However, since this game is physics based and the ball is always moving, any skipping, stuttering or slowdown is visible.

I am seeing the stuttering issue on an iPhone 5 but it is not visible on the engine Game window. Using the free version of Unity, I do not have access to the profiler.

Any ideas why these two bits of script are causing stuttering issues?

Thank you

This is a countdown timer. When the timer reaches zero, the game advances to the next level.

 //Countdown Timer (Visible)
             
 var endTime : float;
 var textMesh : TextMesh;
      
 function Start()
 {
     endTime = Time.time + 63;
     textMesh = GameObject.Find ("Text_Timer").GetComponent(TextMesh);
     textMesh.text = "63";
 }    
 
 function Update()
 {
     var timeLeft : int = endTime - Time.time;
     if (timeLeft < 0) timeLeft = 0;
     textMesh.text = timeLeft.ToString();          
 }
    
 //End level and load win screen after X Seconds (Invisible)        
 var timeLimit : float = 63; // 1 minute timer
  
 Invoke("NextMap", timeLimit);    
 function NextMap() 
 {
     Application.LoadLevel("Win");
 }

This is a quit game button which takes the player back to the main menu.

 private var ray : Ray;
 private var rayCastHit : RaycastHit;
  
 //Load Previous button
 function LateUpdate ()
 {
     //Load Previous Level        
         if(Input.GetMouseButtonDown(0))
     {
         ray = Camera.main.ScreenPointToRay (Input.mousePosition);
         
         if (Physics.Raycast (ray, rayCastHit))
         {
             if(rayCastHit.transform.name == "Text QuitToMenu")
             {
                 Application.LoadLevel("L0.0 Menu");
             }                
         }              
     }         
 }
Comment
Add comment · Show 3
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 Berkays · Apr 13, 2013 at 09:03 PM 0
Share

I think garbage collection mechanism works to clear the previous level cache you might want to check the profiler when running on iphone to clarify the real problem.You should also use CoRoutines for time checking ins$$anonymous$$d of looking up for it every frame and you might want to try loadAsync

avatar image Knoxley · Apr 24, 2013 at 03:44 AM 0
Share

Thank you for the info. Unfortunately, I am using the free version of Unity, I do not have access to the profiler. Nor does the free version make loadAsync available.

avatar image Knoxley · Apr 24, 2013 at 05:29 AM 0
Share

I have gotten rid of the quit game button and simplified the countdown timer to the following. Yet it still hitches at exactly the same spots every time. No matter when I start the timer, the game hitches at 54 and 53 seconds on the countdown.

Here is my updated/simplified countdown timer.

 var timer: float = 60; // set duration time in seconds in the Inspector
 
 
         function Update()
         {
             timer -= Time.deltaTime; // I need timer which from a particular time goes to zero
 
             guiText.text = timer.ToString("F0");
 
         } 

1 Reply

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

Answer by Knoxley · Jul 11, 2014 at 09:47 PM

Turns out, it was the 3D Text turning on and off. It was creating a texture right then that was causing the game to pause momentarily. I solved this by adding those letting in a preload area of the game.

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

11 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

Related Questions

Game stuttering only in iPhoneX and above. Not a performance issue. 0 Answers

iPhone 4S performance issues 6 Answers

Low frame rate with only one texture on iPad 4 Answers

Poor fog performance on the iPad? 2 Answers

What could cause a periodic "freeze" with no memory or cpu spike? 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