Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Jehutyver10 · Sep 06, 2019 at 01:54 AM · physics2daddforcejitter

[Advanced] AddForce Jitter

I've struggled with this question for years now and there is no good answer anywhere on the internet as far as I can tell.

I am simply trying to take in input from the player during Update() and then do this

Rigidbody2d.AddForce(new Vector2 (inputx, inputy) * Time.deltaTime)

During FixedUpdate(). Somehow, even when I release the input, at a certain point it starts jittering. My physics timestep is 0.2. Please, once and for all, how do I move the player character with AddForce with no stutter?

Comment
Add comment · Show 2
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 TreyH · Sep 06, 2019 at 12:23 PM 0
Share

Is the player stuttering or does it just look like they're stuttering due to your camera setup? Have you tried moving the character with a detached stationary camera?

avatar image Jehutyver10 TreyH · Sep 06, 2019 at 06:27 PM 0
Share

The platforms it moves across while stuttering do not stutter, but when I deactivate the following script I have it doesn't seem to jitter, at least not as much. However, every answer I find for smooth camera does what I'm doing: get the position of the player and camera in update, then update the camera's position with a lerp in LateUpdate().

I'm extremely confused.

2 Replies

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

Answer by Jehutyver10 · Sep 06, 2019 at 06:31 PM

I solved it: The answer, once and for all, is to put the camera's tracking method in FixedUpdate since the force is being added in FixedUpdate; this will make the two actions synchronize.

At long last, I have an answer. Future frustrated devs, gaze upon my struggle and learn!

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
avatar image
0

Answer by Pangamini · Sep 06, 2019 at 08:32 AM

Time.deltaTime is a time difference between Update() calls. If you are applying the force in FixedUpdate(), you should use Time.fixedDeltaTime.

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 Bunny83 · Sep 06, 2019 at 12:08 PM 0
Share

This won't change anything and isn't recommended since Time.deltaTime will already return the right delta time value depending on where it's used. See fixedDeltaTime:

For reading the delta time it is recommended to use Time.deltaTime ins$$anonymous$$d because it automatically returns the right delta time if you are inside a FixedUpdate function or Update function.

avatar image Pangamini Bunny83 · Sep 06, 2019 at 12:29 PM 0
Share

Wow, is that new? Or was it always like that?

avatar image Bunny83 Pangamini · Sep 06, 2019 at 12:56 PM 0
Share

It always was like that ^^.

avatar image Jehutyver10 · Sep 06, 2019 at 05:58 PM 0
Share

Thank you for your answer but this follows the exact pattern I found trying to answer this question:

  1. Someone asks how to remove jitter

  2. Someone posts a solution.

  3. Someone else says why that solution won't work.

  4. The question remains unanswered.

I hate to be a bother but do you have any other possible solutions? Thank you again.

avatar image pironc Jehutyver10 · Feb 06, 2021 at 11:18 AM 0
Share

You can try to set the Rigidbody2D's "Collision Detection" mode from "Discrete" to "Continuous".

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

116 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How long addforce applied? 0 Answers

RigidBody2D Performance with AddForce on WakeUp 1 Answer

Rigidbody2d.addforce in the direction of mouse problem 1 Answer

Circular movement using AddForce() 1 Answer

Is it possible to have slow acceleration and high drag at the same time? 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