Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  problem with changing distance constraints parameters through script
#1
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;
        
        
    }
Reply
#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
#3
(20-08-2018, 04:32 PM)josemendez Wrote: 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.
hey , thanks man. it works  Sonrisa 
do you think there is a way to freeze the rope's position on one of the axis ?something like rigidbody constraints, i just need the rope not to swing on X axis
Reply
#4
(21-08-2018, 05:19 PM)h00man Wrote: hey , thanks man. it works  Sonrisa 
do you think there is a way to freeze the rope's position on one of the axis ?something like rigidbody constraints, i just need the rope not to swing on X axis

Nope, there's no way to do that. You can use 2D mode (which restricts particle movement to the XY plane), but other than that there is no way to constraint rope movement to an arbitrary plane.

You could try sandwiching it between two invisible colliders, I think it's the easiest approach (even if slightly hackish).
Reply
#5
(21-08-2018, 08:13 PM)josemendez Wrote: Nope, there's no way to do that. You can use 2D mode (which restricts particle movement to the XY plane), but other than that there is no way to constraint rope movement to an arbitrary plane.

You could try sandwiching it between two invisible colliders, I think it's the easiest approach (even if slightly hackish).

ok, thanks for your answer. i'll try one of them  Gran sonrisa
Reply