21-08-2023, 06:43 AM
(19-08-2023, 07:36 AM)lacasrac Wrote:Code:public void Disable()
{
//solver.enabled = false;
for (var i = 0; i < _solver.velocities.count; i++)
{
_solver.velocities[i] = Vector4.zero;
_solver.angularVelocities[i] = Vector4.zero;
}
positions.Last().transform.GetComponent<Rigidbody>().isKinematic = true;
}
public void Enable()
{
//solver.enabled = true;
positions.Last().transform.GetComponent<Rigidbody>().isKinematic = false;
}
So I have this code on my rope. I attached a Cube with 4 ropes, in the corners.
When I disable it, I want to the rope rest in position. (positions.Last is the rigidbody attached to the 4 fixedjoint)
1, So I disable all my ropes with this code
2, After it I just set back the positions/rotations to default to all my fixedjoints
3, Enable the rope again
Result -> ropes jumping back
I just want to stay there
Hi,
This works fine for me, no rope jumping. If you are modifying any rigidbody/joint properties while the solver is disabled (you mention resetting position and rotation fixed joints) in a way that violates solver constraints, ropes will of course jump back to the closest configuration that doesn't violate any constraints (collisions, attachments, distance, bending, etc) once you re-enable the solver.
The only way to prevent this is by resetting particle positions together with joints yourself, in order to meet all constraints: make sure attached particles are at the position they should be attached to, make sure they're not stretched or over-bent, etc.
kind regards,