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
2
Question by instruct9r · Nov 02, 2014 at 01:15 PM · movementiosfpsfixedupdatejitter

Proper Fixed Timestep for 30 FPS

Hello.

I am having this issue, where my whole game jitters (Small fast jumps every few seconds).

The game runs on iOS device with about 40 FPS, but i've decided to limit it to 30FPS with Application.targetFrameRate.

The problem is that if i leave the fixed Timestep to 0.2 or 0.25 the game jitters all the time. It's pretty tiny jitterring and barely noticeable, but it's there.

So i've decided to set the Fixed Timestep to 0.033333, which shoud be for 30 fps. Anyway, the game now runs super smooth, but these jitters occurs at some point, (Like every 4, 5 seconds).

I am reading from 2 days, what's been discussed in the forums the jitter camera problem, from the LERP, but there's no clear answer on that. My player moves with FixedUpdate and the camera follows it with FixedUpdate...

So my questions are:

What is the proper Fixed Timestep for 30FPS?

If the game can run with 40, 45FPS, shoud i limit it to 30, or leave it on it's own?

What coud be causing the jitter if the game runs with good FPS? When i limit the game to 30FPS and when i monitor the FPS, its allmost perfectly staying on 30FPS (It goes from 29.94 to 30.05). So coud these variations cause the jitter every few seconds, if the Fixed Timestep is 0.033333 ?

Any advice will be appreciated, to stop that jitterring...

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

1 Reply

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

Answer by Bunny83 · Nov 02, 2014 at 02:09 PM

Never, ever move your camera in FixedUpdate. FixedUpdate will never be in sync with the visual update. You should move your camera in LateUpdate in most cases. Increasing the fixed timestep (so lowering the fixed framerate) will just increase the possible jitter (the amplitude of the jitter). When you use FixedUpdate i guess you use rigidbodies and the physics system. If not, get your code out of FixedUpdate and move it to Update. However if you use the physics system only keep stuff in FixedUpdate that is really physics related. Everything else should be in Update or LateUpdate.

Since we don't know very much about your project it's difficult to give any more precise advices.

(Some time ago i made this FixedUpdate simulation to show how it's actually working)

Comment
Add comment · Show 10 · 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 instruct9r · Nov 02, 2014 at 02:20 PM 0
Share

I was just going to write, that before someone advicing me to move the camera movement to Update, i allready did that. Doesn't help... And why everyone gives that advice, when Unity, in both their tutorials "Project - S$$anonymous$$th" and "Project - Survival Shooter" are moving their cameras in exactly FixedUpdate. If it's that wrong, woud they do it this way? I think this whole problem is not involving at all the movement of the camera, because i tested everything. I tried Lerping the camera, i tried with smoothDamp in both Update and FIxedUpdated. DOesn't work. The game still jitters. And it's not only the camera....

THere are no rigidBodied, that the camera follows, just a character with CharacterController. But isn't it physics object? As far as i know the CharacterController moves under the rules of FixedUpdate, so if i make my camera to follow it with Update, the character will start jumping (forth / back).

Also, if highering the FixedTimestep will make the things worst, why it smooths the movement? When i set the FIxedTimestep to 0.02 the camera movement jitters all the time, when i set it to 0.03333, it jitters once, every 4, 5 seconds, which is better in some way..

Thanks for the help :)

avatar image Bunny83 · Nov 02, 2014 at 05:24 PM 1
Share

The character controller isn't physics related. It does it's own collision detection. $$anonymous$$oving the CharacterController in Update will never make it jump forth and back. That would most likely happen when you move the camera in FixedUpdate ins$$anonymous$$d of LateUpdate, I've never looked at any of the recent tutorials, but just for reference i'm just downloading it...

Yes the s$$anonymous$$lth project works with a rigidbody and not with the character controller. When using a rigidbody you have to move it with FixedUpdate and you will always have some sort of jitter. In the s$$anonymous$$lth project they move the camera in FixedUpdate to remove the character jitter. On the other hand everything else will jitter. Since they use a smooth damping for the camera and the framerate is quite hight the jitter isn't that visible. Try lowering the fixedTime step to 0.03333 and set a targetframerate of 30 and you will also have a jitter every now and then.

How often you see the jitter depends on the interference frequency of both, the visual framerate and the fixed framerate. If they are almost the same, the difference between those two frame rates will be a very slow frequency (something between 0.5 and 0.01 Hz). However the amplitude of the jitter depends only on the fixed-framerate. When i'm playing the s$$anonymous$$lth project in the editor at 300fps and move the camera in update, everything is smooth except the character. But if i set the fixed timestep to 0.001 ( == 1000fps) the jitter isn't visible anymore. That's because i get about 3 physics updates between each visual frame. The amount the player is off is just a tiny fraction of the movement that happens between each update.

To $$anonymous$$imize the jitters amplitude and frequency you would have to increase the fixed framerate to a exact multiple of your visual framerate. Since they will never be in sync you will still get that jitters every now and then, but the higher your fixed framerate, the smaller the jitters will be.

Of course you can't push the fixed framerate too much, especially on mobile, but if you use FixedUpdate it's impossible to remove the jitter completely.

avatar image instruct9r · Nov 02, 2014 at 05:42 PM 0
Share

Thanks a lot for the explanation, that makes some sence.

Anyway I am wondering, if my camera follows the player with the Update, shoud my player also move with the Update? If my player moves with FixedUpdate and Camera moves with Update there shoud not be jitter, cuz the camera refreshes faster than the player right?

avatar image instruct9r · Nov 02, 2014 at 05:51 PM 0
Share

What's weird also is that, if i lower the FixedTimestep to 0.01 the framerate of the game falls down to 17 FPS. If i keep it at 0.02 or 0.025 it stays at 30FPS. So the verry small Fixed Timestep impacts the FPS?

the game is for iOS i don't know if i mentioned that..

avatar image instruct9r · Nov 02, 2014 at 07:26 PM 0
Share

ANd one more thing. I will make the FixedFramerate to be 40, ins$$anonymous$$d of 30. But what shoud i do with Fixed TimeStep?

Shoud i leave it to 0.02, or make it 0.033333?

thanks

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.

Follow this Question

Answers Answers and Comments

27 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Can I change movement from Unity 3d into Unity 3D iOS 2 Answers

Why target frame rate either 60 or 30, how about 50? 3 Answers

How to make an object moving in a certain direction, move in specific steps like 0.1f 1 Answer

GameObject.FindGameObjectsWithTag - How CPU Intensive is it (iOS)? 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