• 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 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 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.

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

115 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

Related Questions

How to use AddForce and Velocity together 1 Answer

Unity 2D Physics .AddForce 1 Answer

Jump problem 1 Answer

Adding force at an angle 2D,Adding force at an angle 1 Answer

I'm so lost trying to add a force towards the nearest collder with tag "x" 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges