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 TruffelsAndOranges · Jun 30, 2015 at 11:41 PM · 2d2d game2d-physics2d animation2d-gameplay

Stuttering in simple 2D game using interpolation?

Basically all my movement is stuttering in a very simple 2D game (also if I build the game). It looks as if I have an average framerate of ~10 FPS even though profiler says I have ~1000 FPS.

I do everything according to the "book": everything that is moving is using a 2D rigidbody with interpolation. I only move objects by changing movement speed (and never move/translate game objects directly). The camera update is in LateUpdate. I've turned vsync both off and on without any improvement.

What is even weirder is that this behaviour seems to come at random times. Sometimes when I run the game I have no stutter (like ~1/10 times).

I have a feeling there is something wrong with the interpolation used in Unity.

Help!

Comment
Add comment · Show 4
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 Firedan1176 · Jun 30, 2015 at 11:53 PM 1
Share

So you're moving with rigidbody? Are you changing rigidbody.velocity? I've noticed that it causes a jumping effect, but certainly not making it look like 10fps.

Try adding a simple script with this in the update, place it on a cube, and see if it looks like it's 10fps:

 void Update() {
 
     transform.position += new Vector3(Vector3.left * Time.deltaTime, 0f, 0f);
 
 }

If you put this on an object in game, does it look like it's stuttering?

I feel like the problem is simply the LateUpdate rate. It's called every 0.2 seconds defaultly, so you may want to look on how to change physics update rate, and make it more like 0.1 or 0.05. It's less efficient and performance heavy, though

avatar image TruffelsAndOranges · Jul 11, 2015 at 08:39 PM 0
Share

Hey! Thank you for the answer. Gave a thumbs up for trying to help! :-)

I'm moving objects with a rigidbody using only rigidbody.velocity. I have constant 200 FPS and still get stuttering; even when I build the game! I'm starting to think that there might be an issue with the interpolation that Unity is using.

I'll try just moving objects directly ins$$anonymous$$d and see what happens!

LateUpdate called every 0.2 seconds by default? That sounds really weird. Are you sure about that? I feel like the camera is not really stuttering... more as if the rigidbodies are stuttering.

avatar image maccabbe · Jul 11, 2015 at 10:26 PM 1
Share

Pretty sure that Firedan1176 mixed up FixedUpdate with LateUpdate because LateUpdate is stated to be frame dependent (like Update) in the documentation.

http://docs.unity3d.com/ScriptReference/$$anonymous$$onoBehaviour.LateUpdate.html

http://docs.unity3d.com/ScriptReference/$$anonymous$$onoBehaviour.FixedUpdate.html

avatar image TruffelsAndOranges · Jul 11, 2015 at 10:44 PM 0
Share

Thank you for answer. I gave you a thumbs up for helping.

maccabbe I think so too! I have tried changing my FixedUpdate rate but with no success. Also tried different values of $$anonymous$$aximumFixedTimeStep!

1 Reply

· Add your reply
  • Sort: 
avatar image
-1

Answer by DimitriUK · Jul 11, 2015 at 10:34 PM

It sounds like you need your camera to follow in an FixedUpdate() function, check to see if your camera follow script is Update(), if so, change that now and it should work.

Good luck with your project.

Comment
Add comment · Show 2 · 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 TruffelsAndOranges · Jul 11, 2015 at 10:43 PM 0
Share

As mentioned above the problem exists even if the camera is stationary! $$anonymous$$oving the camera follow to FixedUpdate() will also create other problems. The camera following should be in LateUpdate().

avatar image DimitriUK · Jul 11, 2015 at 11:03 PM 0
Share

Apologies, I never read the comments above. I was answering from my experience with laggy objects such as Rigidbodys, etc. I just remember I did FixedUpdate and changed the Rigidbody's interpolation to one of the two and it finally worked.

If neither of that works, I'm really sorry, I can not help.

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

so I'm trying to make a 2D platform but the first animation i make is the only one that registers 0 Answers

[Solved] Does Unity's 2D Tilemap Editor 1.0.0 Include Rule Tiles? 1 Answer

2D Z-Levels HELP Needed! Can I script multiple objects to run on z levels,,2d Multiple Z levels in one scene 0 Answers

Having some stuck issues on the 2D infinite runner 0 Answers

When 2D Car Turns Upside Down, Game Over Scene Should appear. 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