Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  problem with changing distance constraints parameters through script
#2
(20-08-2018, 10:10 AM)h00man Wrote: hi, i been trying to make a grapple hook similar to the included one in the package,when i shoot the hook game object and it sticks to other objects i need the robe to be much less stretchy.im using a simple script to control the prematers of distance constraints ,it works fine and it changes the parameters correctly .the problem is , it only changes the numbers .the real changes only going to be applied when i insert the numbers to obi solver manually.
how do i change the distance parameters like iteration and relaxation by script and see it actually happen in the play mode?
and here is the code:

public void less stretch()
    {
        obiRopi.GetComponent<ObiSolver>().distanceConstraintParameters.iterations = 38;
        obiRopi.GetComponent<ObiSolver>().distanceConstraintParameters.SORFactor = 1.5f;
        
        
    }

Hi,

Just call
Code:
obiRopi.GetComponent<ObiSolver>().UpdateParameters();
after you've set the new values.

Hint: reducing Unity's timestep or increasing the amount of solver substeps might work much better for reducing rope stretchiness.
Reply


Messages In This Thread
RE: problem with changing distance constraints parameters through script - by josemendez - 20-08-2018, 04:32 PM