For some reason the SpringJoint class has connectedMassScale, a very handy feature that doesn’t seem to be available in SpringJoint2D…
What would be the best way to replicate this behavior in a 2d context?
For some reason the SpringJoint class has connectedMassScale, a very handy feature that doesn’t seem to be available in SpringJoint2D…
What would be the best way to replicate this behavior in a 2d context?
They are completely different physics engines i.e. PhysX (3D) vs Box2D (2D) so there isn’t exact feature parity.
You cannot unless you create your own script-based spring constraint.
As for what I’ve tested in 3D physics, the effect of connectedMassScale is no different than just scaling the mass of the connected object. Indeed as for my tests that’s what it does.
Not a 3D physics guy here but yes, I believe it’s a temporarily scaling thing only active during the joint solver for that specific joint without having to permanently change the actual mass for other forces such as collisions etc?
I’ve personally never used it. Effectively changing the mass of both bodies would achieve the same thing as long as you didn’t need some other mass for some other reason.
That’s what I also believed, that it would be something applied to the calculations at some stage only. But the tests show that this option applies a scale to the connected mass equivalent to… just scaling the mass in the connected rigidbody. Even the total weight of the object increases accordingly.
Wow, thanks for the info. That’s almost to the point of being weird though!
I wonder what happens if you use multiple joints. It seems very weird that it’s not a “local” effect.
I learned something today.
Yes, exactly! I might be missing something, but in the past I spent quite a few time researching ways to stabilize joints without increasing the physics rate, and that was the result of testing the connectedMassScale option.
I haven’t tested circular joint connections, but the effect was the same in a chain of joints. connectedMassScale simply increased the mass of the referred body, so that part of the chain becomes more stable (and more heavy).
So far, the best way I found to stabilize joints without modifying the masses is scaling the inertia of the Rigidbodies when there’s a significant difference between the connected masses. Of course, abusing this option also has its consequences (like a “dragged” motion), but it works fine without noticeable effect in most situations.
I asked the 3D physics team about this earlier so on Monday I might have more info. Just curious really. It wouldn’t be hard to add this to 2D physics but I’d definatley implement it as a solver-only thing for that joints reaction impulses.
I’m very curious too, let me know what they say.
Thanks for the answers, on my side for my use case, I switched to PhysX entirely and work it without using the 3rd axis. It was easier since I’m still in a context of a prototype.
Although I’m very curious to hear the result of this investigation.