Obi Official Forum
Help Changing rope solver constraints settings with script - 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 Changing rope solver constraints settings with script (/thread-3634.html)



Changing rope solver constraints settings with script - Zombie1111 - 06-11-2022

Im trying to change the distance iterations option at runtime using a script but I cant get it to work!
Doing this does nothing
grab_holdingRope.solver.distanceConstraintParameters.iterations = 20;
grab_holdingRope.UpdateParticleProperties();

Doing this causes the rope to "drag itself" and fly around all over the place. (Calling both UpdateParticleProperties and UpdateBackend have the same effect)
grab_holdingRope.solver.distanceConstraintParameters.iterations = 20;
grab_holdingRope.solver.UpdateBackend();

Changing the distance iterations option at runtime using the inspector does work! So I guess there is a function or something that I must call after changing the option!? But idk what that function is called and I have tried calling many different functions with no luck.


RE: Changing rope solver constraints settings with script - josemendez - 07-11-2022

(06-11-2022, 08:45 PM)Zombie1111 Wrote: Im trying to change the distance iterations option at runtime using a script but I cant get it to work!
Doing this does nothing
grab_holdingRope.solver.distanceConstraintParameters.iterations = 20;
grab_holdingRope.UpdateParticleProperties();

Doing this causes the rope to "drag itself" and fly around all over the place. (Calling both UpdateParticleProperties and UpdateBackend have the same effect)
grab_holdingRope.solver.distanceConstraintParameters.iterations = 20;
grab_holdingRope.solver.UpdateBackend();

Changing the distance iterations option at runtime using the inspector does work! So I guess there is a function or something that I must call after changing the option!? But idk what that function is called and I have tried calling many different functions with no luck.

Hi!

The function you're looking for is solver.PushSolverParameters().

As per the API docs:
Quote:void Obi.ObiSolver.PushSolverParameters()
Updates solver parameters. Call this after modifying solver or constraint parameters.

UpdateParticleProperties() is an internal method that updates particle properties (has nothing to do with constraints) and UpdateBackend() checks whether the solver's backend has been changed (for instance, from Oni to Burst) and if so, it tears down the old backend and reinitializes the solver using the new backend. Neither of these are related to solver/constraint parameters in any way.

kind regards,