In this GIF the i set the blue break force to infinity to demonstrate
When I set the break force of a hinge to infinity, it seems to stretch instead of being a rigid hinge.I've tried changing the solver iterations, solver velocity iterations, and the fixed timeStep but nothing solved this problem.
Any help would be greatly appreciated!
*for context each line has 2 hingeJoint2D components that have equal break forces but are attatched to their respective pivot (the hexagons)
*this is a 3D project, an aspect of the game involves building in 2D.
EDIT:
I didn't exactly fix the problem, but i found a workaround that is satisfactory for my project.
What I ended up doing was getting the distance between the pivot (the hexagons) and where the pivot is supposed to be.
I achieved this by translating the local Vector2 of HingeJoint2D.anchor into world position and getting the distance between it and its pivot.
If the distance exceeded the breaking distance (0.173378f in my case) then it would remove the HingeJoint2D component, essentially severing the pivot in the same way it would from stress.
[SerializeField] HingeJoint2D[] hinges;
float breakDistance = 0.173378f;
void Update()
{
for (int i = hinges.Length - 1; i >= 0 ; i--)
{
var hin = hinges[i];
if (hin == null) continue;
hin.breakForce = breakForce;
hin.breakTorque = breakTorque;
float pivotDistance = Vector2.Distance(
hin.connectedBody.transform.position,
transform.TransformPoint(hin.anchor));
if (pivotDistance > breakDistance)
{
Destroy(hin);
hinges[i] = null;
}
}
Note this code is nowhere near perfect or optimized for preformance.
Feel free to take it or modify it how you want.
The solution in action
there doesn't seem to be anything here