Obi Official Forum
Help Moving Local-Space Solver causes child Cloth to jump & tear? - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Cloth (https://obi.virtualmethodstudio.com/forum/forum-2.html)
+--- Thread: Help Moving Local-Space Solver causes child Cloth to jump & tear? (/thread-1227.html)



Moving Local-Space Solver causes child Cloth to jump & tear? - jabza - 15-06-2019

***Update: Setting Solver to LateUpdate appears to fix this, but should this even be needed? Not a desired solution. ***

Hi,

I have one ObiSolver set to Local-Space, with five TearableCloth actors as children.

When teleporting the parent GameObject of this Solver, the cloth appears to 'snap jump', and sometimes even causes tearing.
Implying forces from Global-Space are effecting the actors?

This has puzzled me, as I'd expect this behavour with a Global-Space Solver, but not Local. 
Please see my Sovler configuration below - Obi version 4.1:

[Image: 1LnwSKn.png]

What I am observing, the moment of the parent Transform 'teleport', the TearableCloth is locally offset for one frame:
[Image: MP3x2l5.png]

At the next frame, we see the Cloth 'stretching' back:
[Image: tavErpN.png]

Again, I'd expect this behaviour if my Solver was global space, not local space. Is this a correct assumption?

Thanks again for the support, much appreciated.

Cheers,
Jabza


RE: Moving Local-Space Solver causes child Cloth to jump & tear? - josemendez - 17-06-2019

(15-06-2019, 10:42 PM)jabza Wrote: ***Update: Setting Solver to LateUpdate appears to fix this, but should this even be needed? Not a desired solution. ***

Hi,

I have one ObiSolver set to Local-Space, with five TearableCloth actors as children.

When teleporting the parent GameObject of this Solver, the cloth appears to 'snap jump', and sometimes even causes tearing.
Implying forces from Global-Space are effecting the actors?

This has puzzled me, as I'd expect this behavour with a Global-Space Solver, but not Local. 
Please see my Sovler configuration below - Obi version 4.1:

[Image: 1LnwSKn.png]

What I am observing, the moment of the parent Transform 'teleport', the TearableCloth is locally offset for one frame:
[Image: MP3x2l5.png]

At the next frame, we see the Cloth 'stretching' back:
[Image: tavErpN.png]

Again, I'd expect this behaviour if my Solver was global space, not local space. Is this a correct assumption?

Thanks again for the support, much appreciated.

Cheers,
Jabza

Where in Unity's update cycle are you moving the solver around? FixedUpdate, WaitForFixedUpdate, Update, LateUpdate...


RE: Moving Local-Space Solver causes child Cloth to jump & tear? - jabza - 17-06-2019

(17-06-2019, 07:00 AM)josemendez Wrote: Where in Unity's update cycle are you moving the solver around? FixedUpdate, WaitForFixedUpdate, Update, LateUpdate...

I'm currently moving the parent object of the Solver in LateUpdate, and I've set the script performing the action as the last to run in the 'script execution order' list.

For context, this is a floating origin implementation I'm using. Any ideas?

Thanks again.


RE: Moving Local-Space Solver causes child Cloth to jump & tear? - josemendez - 17-06-2019

(17-06-2019, 02:49 PM)jabza Wrote: I'm currently moving the parent object of the Solver in LateUpdate, and I've set the script performing the action as the last to run in the 'script execution order' list.

For context, this is a floating origin implementation I'm using. Any ideas?

Thanks again.

Hi there,

You should move your ship *before* the physics update for the solver happens, or a 1-frame delay will be introduced. The solver has lots of events for you to hook up custom code to. You should probably use solver.OnStepBegin, that is called right before each physics step. However, this alone won't help with teleporting.

Take a look at the ObiActorTeleport.cs script. (found in Obi/SampleScenes/SampleResources/Scripts). To teleport an actor, you should:
-disable it.
-teleport it.
-wait for the next FixedUpdate and re-enable it.

Carefully scheduling the order in which things should happen each frame is of vital importance when working with physics, as it is easy to introduce jitter/lags if using an incorrect setup.


RE: Moving Local-Space Solver causes child Cloth to jump & tear? - jabza - 17-06-2019

(17-06-2019, 07:18 PM)josemendez Wrote: Hi there,

You should move your ship *before* the physics update for the solver happens, or a 1-frame delay will be introduced. The solver has lots of events for you to hook up custom code to. You should probably use solver.OnStepBegin, that is called right before each physics step. However, this alone won't help with teleporting.

Take a look at the ObiActorTeleport.cs script. (found in Obi/SampleScenes/SampleResources/Scripts). To teleport an actor, you should:
-disable it.
-teleport it.
-wait for the next FixedUpdate and re-enable it.

Carefully scheduling the order in which things should happen each frame is of vital importance when working with physics, as it is easy to introduce jitter/lags if using an incorrect setup.

Great, that was it. I wasn't aware of WaitForFixeUpdate. Teleporting without a hitch now. Cheers!