Hello,
I have a boxcollider, when the player trigger it I want to "move" the rope
But when the player onTriggerExit the rope will be freeze.
How can I do that with attachments? How can I freeze or unfreeze it?
(02-08-2023, 06:00 PM)lacasrac Wrote: [ -> ]How can I do that with attachments? How can I freeze or unfreeze it?
Hi there,
I'm not sure what you mean by freezing/unfreezing an attachment. Attachments simply constrain the relative position of a rope and a target transform/rigidbody, you could freeze either the rope or the transform/rigidbody.
Could you elaborate a bit more?
kind regards
(09-08-2023, 07:05 AM)josemendez Wrote: [ -> ]Hi there,
I'm not sure what you mean by freezing/unfreezing an attachment. Attachments simply constrain the relative position of a rope and a target transform/rigidbody, you could freeze either the rope or the transform/rigidbody.
Could you elaborate a bit more?
kind regards
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
(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,
(21-08-2023, 06:43 AM)josemendez Wrote: [ -> ]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,
I just sent you an example, to your email: support@virtualmethodstudio.com
Can you please check it?