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 jsip · Jan 24, 2015 at 06:42 AM · movementphysicsrigidbodystutter

RigidBody2D Movement Stuttering

I'll get this out of the way - I've tried:

  • Velocity

  • AddForce

  • update * deltatime/smoothdeltatime

  • fixedupdate - changed timestep from 0.2 to 0.01666667 to 0.01, etc

  • moveposition

  • interpolation

  • extrapolation

  • etc

The problem I'm having is that I need to move a rigidbody2D object without it micro-stuttering. I generally run 750+ fps when I build, but that doesn't matter much when even with vsync or limiting the framerate to 60 or 120 doesn't change the behaviour.

I noticed my main player would "vibrate" as he moved along the X axis (I control jumps with AddForce just fine). But applying any kind of physics to the X axis causes him to vibrate. He has NO drag, has a physics material that sets drag to 0 (so I can control all accel and decel on my own). No amount of fiddling with timings, speeds, acceleration, straight setting the velocity, etc will alleviate his micro stuttering. I've tried setting the framerate equal to the timestep and vice versa to try to eliminate pretty much everything i can think of.

I first noticed the rigidbody2D micro stutter when my entire scene would "stutter" since the camera snaps to the player's X axis to follow (in LateUpdate) which caused my parallax which moves based on the camera's position to also stutter.

I unlocked my Camera from the player's X coordinates and now move the camera using Translate and dampen the X ever so slightly to prevent the camera movement from being choppy due to the main player vibrating. I do this by simply getting the distance from the camera's X and the player's X and using a multiplier on that number, use that as my "speed", +-, based on position with a lerp between previous frame and current frame to prevent any stuttering at max speed. It's now smooth as silk no matter what framerate the game plays at, vsync or not - silky smooth.

This is when I saw my main rigidbody2D micro stuttering. Because the environment moved so smoothly and the camera was well controlled, I can now see my player vibrating, stuttering, skipping - which was the entire scene (except the player locked in the center of the screen with my previous camera movement).

I am at a loss. I've been looking for about 2 days through this forum and other avenues to see if I can fix my issues. 99% of the time it's due to misunderstanding a fixed time step, fixed update, framerate, etc. What is odd is that I have a few other rigidbody2D's that move just fine on their own without stuttering.

I also checked to be sure there was no variance of maximum speed by printing velocity of every frame - which is a lot to go through at 1k+ in the editor and 750+ in a build. Every frame, every fixedUpdate, always the same.

I'm pretty clueless, at this point. Help, anyone?

Comment
Add comment · Show 1
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 Hiti3 · Sep 25, 2015 at 08:01 AM 0
Share

WHat have you dont to fix this, please tell us! Help us out here!

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by mactinite77 · Feb 04, 2015 at 07:12 AM

Jsip,

I was running into this problem tonight. I was able to solve(?) it by doing everything in Update, and then changing the fixed timestep to 0.001. I'm not sure how this will perform with a lot of physics objects, but that's what stopped the micro-stuttering to be visible to me.

It doesn't seem like much of a solution, but it was the only way I could do it without ditching Rigidbody2D.

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 Chris75 · Mar 16, 2015 at 04:08 PM 0
Share

Hey mactinite, what do you mean by fixed timestep? I have this exact issue and nothing so far has fixed it. Your reply is different than all others so I wouldn't $$anonymous$$d seeing if yours fixes it.

avatar image mactinite77 · Mar 16, 2015 at 06:20 PM 0
Share

If I'm remembering correctly there is an option under Edit>Project Settings>Time for fixed timestep.

avatar image
0

Answer by jsip · Feb 04, 2015 at 06:45 PM

Thanks mactinite77, I have decided to use Translate instead and roll my own physics.

The problem I am seeing with micro-stuttering is phase shifting between physics updates and framerate. So I create my own math and apply that with translate. Super smooth no matter the fixed timestep.

Mods can close this.

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 Chris75 · Mar 16, 2015 at 04:09 PM 0
Share

Do you $$anonymous$$d sharing what you did? I've tried for weeks to fix this, but am unable to.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

RigidBody immediately stops after AddForce 1 Answer

Unity Physics On Input Issue? 0 Answers

Strange Rigidbody Behavior 0 Answers

Collisions causing Rigidbody to go Haywire and move randomly. 1 Answer

Ground clamping a rigidbody on slope 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