I have been messing around with Physics and specifically joints for a while now and there is one thing that I cannot seam to fix… stretching joints. You can put two objects with rigidbodies and colliders together in space at identical coordinates and when they hit something the joints stretch apart and spring back together.
I know I could set a low break point but these are not big impacts in the grand scheme of things. The completely separated joint in the last image below is from a drop of maybe 6 meters at very slow speed.
In the example of a hinge joint they say its for a door but why would a door stretch off of it’s hinges? I have tried every joint type and every setting. Same results. I have tried very small and very large numbers for mass. Using gravity and not. Again, same result.
hey naruse - I tried everything from 999 to infinity on most joints and they still stretch. Fixed joints don’t even have a setting and they stretch too.
Thx again naruse. Yeah I have messed with every single setting and every single joint type. Again, try this test with a fixed joint and you will see it stretch.
I am basically hoping someone from the Unity team will step up and say “Yes, it does stretch and there is nothing that you can do about it” or “No, here’s how to fix it…”
You can reduce the stretching effect by reducing ‘Fixed Timestep’ in Edit > Project Settings > Time > Fixed Timestep. The bad news is that this increases the load on the physics calcs, so your FPS will take a hit.
Cool thx Simon. I think I am at .02 already but I will mess with it a bit more. Maybe increasing solver iteration count will help too. Beyond the basic uses of physics in Unity it all seams very mysterious. A lot of numbers to change and sometime you don’t see any visual result.
Its a hell of a lot of fun when it does work right though!
I also had great difficulties with the stretching joints. I ended up adding a coroutine that repositioned the local position at a fixed interval. But a ‘lock’ parameter would be great.
Yes, I would also like this. I also requested, a long while back, to be able to measure the “tension” on a joint. That what I can determine whether the joint is stretching and by how much.
Not sure if this will help, but I had the same problem trying to do 2D car physics. When I accelerated or hit the brakes, the wheels would get pushed or pulled forward and back instead of staying locked to the Y axis. I ended up using a workaround, which was to do the physics on invisible wheels, with the visible wheels using their position as a reference, but with restrictions, such as locking them to the Y axis and keeping the wheel within the suspension’s limits. It didn’t solve the real problem, but it hides it pretty well.
Any chance to see the physical materials applied to ground and wheels?
Did you try it with realistic values?
Infinite break force and break torque for example are are very unrealistic, as thats an infinite force against the cycles body from the joint which causes the massive torque your see on the screen with the body beeing rotated by about 60°.
Normally it would be around 20-40° or if the spring is completely stiff, a “salto” over the front wheel or pure slide (depending on the setup of the physical materials of wheel and ground) would be the consequence. What it never will do is not compress the spring while going into instant standstill.
Thats physically completely impossible.
Such “game physics” would be something you either have to develop yourself or need to be achieved through coded physics changes, which means that the moment you break your script must basically kill the whole inertia in the system.
Why not just put your collider as a child of the rigidbody. Make sure to NOT put a rigidbody or joint on the collider, this way Unity will group it directly with the parent Rigidbody.
I spent a lot of time trying to figure this out, and eventually realized there’s no such thing as a non-stretchable joint. I tried every type of joint, every possible setting, tried every suggestion I could find, and the joints always stretch. If you need a fixed joint that never stretches, don’t waste your time trying to do it with the physics engine.
@John-B , that’s my conclusion as well. Although I only recently learned that unity’s mass is totally arbitrary and not based on kg. I find I get much better joint behavior if I keep mass in the 5-10 units range. I get much less stretching if I stick to this.