Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Jitter of softbody when moving attachment
#1
Hi!

I have an attachment (static) that targets obi rigidbody which is child of my player.
When player moves in update, softbody jitters.
If my player moves in FixedUpdate() and Cinemachine Brain is set to FixedUpdate, there is no jitter, but the problem is that I can't use this setup (it breaks other stuff).

Is there a way to move attachment's target in Update() without causing softbody to jitter?
If I move target in editor (with gizmos), it seem that softbody is not jittering. Same, if I unparent target and move it by code.

It seems that the problem is in parent-child relation, but I can't figure it out.
If I just unparent target and move it to desired point (which is child of player) by setting Transform properties, or even by moving target's rigidbody (with interpolation or not) by rigidbody.MovePosition/MoveRotation, the jitter is there.
Same if I remove obi rigidbody and rigidbody from target.

No jittering when using Obi Late Updater, but simulation differs with different framerates, so I can't use it too

Please help.
Reply
#2
(12-05-2023, 12:16 PM)luvjungle Wrote: Is there a way to move attachment's target in Update() without causing softbody to jitter?

If the softbody is updated in FixedUpdate - which is where physics should always be updated if you want consistent behavior -  it is not possible to get rid of jitter because Update is called at a variable frequency, while FixedUpdate is called at a fixed frequency.

Some frames Update will be called and FixedUpdate won't, some frames Update will be called and FixedUpdate will be called multiple times. As a result, some frames the attachment target will move but the softbody won't, and some frames the softbody will move more than the attachment, leading to jittering since they're updated at different times.

(12-05-2023, 12:16 PM)luvjungle Wrote: If my player moves in FixedUpdate() and Cinemachine Brain is set to FixedUpdate, there is no jitter, but the problem is that I can't use this setup (it breaks other stuff).

This is the correct setup, physics (and anything interacting with physics) should be updated in FixedUpdate.

Another possibility is to update physics in LateUpdate (using Obi Late Updater), but this of course makes the simulation dependant on the time passed between updates which is physically incorrect and should only be used as a last resort.

Unfortunately there's no way to get rid of jittering if you update things at different frequencies. You must either update everything in Update/LateUpdate, or update it in FixedUpdate.


kind regards,
Reply
#3
Thanks!

I think I need to try another approach, as my objects maps to softbody's particle positions and rotations.
I will try to add some damping/interpolation on this step and stop trying to do something with attachment =)
Reply