Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Best time to change rope length?
#2
(01-07-2020, 03:41 AM)protomenace Wrote: Is there a preferred time in the game/physics loop to change the length of a rope with an ObiRopeCursor? Is there a time at which it would be the least disruptive to the Obi physics simulation?  For example, will the rope be better behaved if I were to update the length of the rope during an ObiSolver.OnSubstep callback? Or maybe just during FixedUpdate? I assume changing the length of the rope in Update() would be quite inconsistent and maybe cause some weird behavior relative to doing so as part of the physics loop?

Hi there!

ChangeLength() adds/removes particles to/from the rope, and adjusts the rest length of distance constraints. The engine will "see" these changes and act accordingly during the next physics substep.

So technically, you can call ChangeLength() anywhere. However, for the sake of smoothness it's best to call it on OnSubstep() (using the substep time delta to adjust the amount of length added/removed, just like you'd do in FixedUpdate() with Time.fixedDeltaTime, or Update() with Time.deltaTime). This way the changes in the rope structure are more incremental and the simulation can react to them immediately, instead of waiting until the end of the entire frame. Specially so if you're using multiple substeps.
Reply


Messages In This Thread
Best time to change rope length? - by protomenace - 01-07-2020, 03:41 AM
RE: Best time to change rope length? - by josemendez - 01-07-2020, 09:56 AM