• 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 IceEnry__lol · Apr 06, 2017 at 10:15 PM · fpslagstutterlaggy

60FPS but the game seems lagging

Hi, i made a game, not much complex (with grap$$anonymous$$cs or scripts) but nice. I found a script that shows fps in the game :

 using UnityEngine;
 using System.Collections;
 
 public class fpsshow : MonoBehaviour
 {
     float deltaTime = 0.0f;
 
     void Update()
     {
         deltaTime += (Time.deltaTime - deltaTime) * 0.1f;
     }
 
     void OnGUI()
     {
         int w = Screen.width, h = Screen.height;
 
         GUIStyle style = new GUIStyle();
 
         Rect rect = new Rect(0, 0, w, h * 2 / 100);
         style.alignment = TextAnchor.UpperLeft;
         style.fontSize = h * 2 / 100;
         style.normal.textColor = new Color (0.0f, 0.0f, 0.5f, 1.0f);
         float msec = deltaTime * 1000.0f;
         float fps = 1.0f / deltaTime;
         string text = string.Format("{0:0.0} ms ({1:0.} fps)", msec, fps);
         GUI.Label(rect, text, style);
     }
 }

it shows me (in the build) 63-4 to 70 fps never under 60s (the same if I try the game in the Unity editor with stats active) I even turned down the quality settings a bit (but i t$$anonymous$$nk that is not that the probem, because the game uses 7% of the cpu and 70mb of ram, I have a gt 920m, w$$anonymous$$ch is enough for t$$anonymous$$s game), but sometimes the game seems lagging or stuttering. I don't know why... the camera movement is in the LateUpdate Function, and the player dosen't move with animations but with phyiscs (rigidbody). (my fixed delta time is 0.01 s).

(I even don't know why the "fpsshow" when the game is in the pause menu, timescale 0, shows infinity fps)

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by tanoshimi · Apr 06, 2017 at 10:17 PM

"camera movement is in the LateUpdate Function, and the player dosen't move with animations but with phyiscs (rigidbody)."

That's probably your problem right there. Assuming your camera is tracking your player, have you tried moving your camera movement to FixedUpdate also?

Comment
Add comment · Show 4 · 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 IceEnry__lol · Apr 07, 2017 at 07:14 PM 0
Share
avatar image toddisarockstar · Apr 07, 2017 at 09:57 PM 1
Share
avatar image IceEnry__lol · Apr 08, 2017 at 11:20 PM 0
Share
a.png (192.9 kB)
b.png (112.5 kB)
avatar image Ultroman · Oct 17, 2017 at 02:13 PM 0
Share
avatar image
1

Answer by FortisVenaliter · Apr 06, 2017 at 10:32 PM

Depending on your scripts, it could also be the Garbage Collector. If it runs okay most of the time, but occasionally glitches or freezes momentarily, you may be generating memory every frame w$$anonymous$$ch then needs to be cleaned up. Check out the profiler's GC Alloc column to determine if t$$anonymous$$s is the problem.

Comment
Add comment · Show 5 · 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 IceEnry__lol · Apr 07, 2017 at 07:22 PM 0
Share
avatar image IceEnry__lol IceEnry__lol · Apr 07, 2017 at 07:29 PM 0
Share
a.png (190.1 kB)
avatar image FortisVenaliter IceEnry__lol · Apr 07, 2017 at 08:20 PM 0
Share
Show more comments
Show more comments

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

7 People are following this question.

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

micro Jittering, stuttering... bug of unity? 2 Answers

Laggy 3D game on Android 0 Answers

Odd FPS in Editor & Built game. 0 Answers

Scene and Game Screen Lag 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