Obi Official Forum
Help Multiple rope: Different simulation problem - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: Help Multiple rope: Different simulation problem (/thread-3382.html)



Multiple rope: Different simulation problem - schromercy - 29-03-2022

Hi, i placed 2 ropes on my scene under 1 solver and i notice that they behave differently.
I want my ropes un-extendable so i configured the solver's constraint & substep count.
Strangely it is working on 1 of the rope, but not on the other one (video attached).
How do i solve this?


RE: Multiple rope: Different simulation problem - josemendez - 29-03-2022

Hi,

It just looks like either:

A) one rope is using a dynamic attachment and the other one is using a static attachment.
B) the mass of the objects attached to them is different.

let me know if I can be of further help,


RE: Multiple rope: Different simulation problem - schromercy - 29-03-2022

Hi Jose,
Just checked and both of the ropes have same configuration:
A). Both has dynamic attachment
B). Attach to object with same mass

Do you have any other clue why this happens?
Thx!


RE: Multiple rope: Different simulation problem - josemendez - 29-03-2022

(29-03-2022, 09:42 AM)schromercy Wrote: Hi Jose,
Just checked and both of the ropes have same configuration:
A). Both has dynamic attachment
B). Attach to object with same mass

Do you have any other clue why this happens?
Thx!

Are both ropes using the same blueprint? If that's the case, I can't think of any other culprit. Would you mind to send the scene to support(at)virtualmethodstudio.com so that I can take a closer look?


RE: Multiple rope: Different simulation problem - schromercy - 29-03-2022

Sure, i've sent the project using same title of this thread Sonrisa 
Hope that helps


RE: Multiple rope: Different simulation problem - josemendez - 29-03-2022

(29-03-2022, 10:34 AM)schromercy Wrote: Sure, i've sent the project using same title of this thread Sonrisa 
Hope that helps

Hi!

Took a look at your project, the issue is that you're mixing up velocities and forces.

You change the rigidbody velocity in FixedUpdate() ignoring its mass. Since the solver is also updated in FixedUpdate() but it does take masses into account, the order in which Unity calls FixedUpdate for each object (which as you know is undefined by default) will affect the result. There's two possibilities:

A) if the handle's FixedUpdate is called first, it will change the rigidbody velocity. Then Obi will perform its simulation using this (very large) velocity value, but is able to correct it using the forces applied by the rope. This is what you labeled the "correct" behavior.

B) if the handle's FixedUpdate is called last, Obi will perform the simulation first. Then your handle will set a new (very large) velocity value, that Obi has no chance to correct until the next frame. This is what you labeled "wrong".

Possible solutions:

- Modify your handle script to actually use forces (right now you're using velocity deltas). This:
Code:
_rigidbody.AddForce(desiredForce, ForceMode.VelocityChange);

must be this:

Code:
_rigidbody.AddForce(desiredForce, ForceMode.Force);

This way both Obi and your script use forces and everything will work correctly regardless of update order. It is also the physically correct way to do it, since you want heavier objects to be harder to drag.

Also, I'm not quite sure why you subtract the current's rigidbody velocity from your velocity delta. This will introduce further order dependency, since the velocity at that point might or might not have been altered by Obi yet. If all you want is to drag the object using a force, these two lines are not needed:

Code:
desiredForce -= _rigidbody.velocity;
desiredForce = desiredForce.NewZ(0);

- Explicitly set the order in which you want things to happen, by changing script execution order. Set your TestHandle script to run before all other scripts in the game (including Obi). This will ensure Obi runs after your handle script has modified the velocity, and it can apply a correct force value.


RE: Multiple rope: Different simulation problem - schromercy - 29-03-2022

You are spot on Jose!
So the problem is the conflict between drag physic vs obi physic simulation.

My project do not need to factor mass when dragging, that's why the drag implementation is like that Sonrisa 
And the problem is solved after set the script execution order. Thanks!

 


RE: Multiple rope: Different simulation problem - josemendez - 29-03-2022

(29-03-2022, 12:08 PM)schromercy Wrote: You are spot on Jose!
So the problem is the conflict between drag physic vs obi physic simulation.

My project do not need to factor mass when dragging, that's why the drag implementation is like that Sonrisa 
And the problem is solved after set the script execution order. Thanks!

 

Whichever works best for you! Sonrisa let me know if I can be of further help.