Physics go haywire consistently!

Hello,

I’ve got something of a problem… I’ve got a physics setup that is consistently misbehaving…
The setup is kinda complex… it has a number of stacked bodies, using configurable joints to keep them on the XY plane, and fixed joints so that they’re linked to each other (one is a “root body” with no fixed joint)

This stack works alright when it’s at the origin… it just sits there, until it becomes unbalanced and topples over… not a problem…

The problem is when this stack is propelled (it’s a rocket) to over 1000 units high on the Y axis… what happens there is that everything, all those rigidbodies, start wobbling and jittering out of control (like 1000 units/second out of control)… their velocities start changing constantly, and it’s clear that the physics simulation isn’t working anymore… This happens consistently… there is some variation of the actual point at which the madness starts, but if I leave everything without moving, it stays perfectly stable… could I be suffering from floating point inaccuracies? 1000 units seems too little for that…

As far as scale goes… All bodies are around 1 to 2 units large, with masses around 0.1 and 0.3… no linear drag is applied…

The bodies are propelled by constant forces applied to the lower bodies (children in the fixed joint hierarchy)… these seem to work fine, until, of course, the entire setup goes kablooye :expressionless:

The Fixed Joints are set to break at 5 force and 5 torque, which would work very well, if the whole system managed to keep stable…

As for forces… I’m applying about 10-20 units constant force at a time…

I’m using capsule and box colliders on the bodies… the geometries for them are actually children of the gameobjects that have physics components attached, and is just there visually (I think)… none of the meshes have rigidbodies or colliders attached directly…

As far as the scene hierarchy goes, none of the bodies are parenting another. They are all on scene level… their “hierarchy” is solely based on the fixed joints

The colliders do intersect a bit while connected by the Fixed Joint…

For the physics settings, I’m using 16 iterations, gravity at default -9.81 and all other settings at default…

That’s about all I can say about my setup…
Can anyone shed a light on this? It’s driving me crazy… and it’s a core feature of the project, so it’s really important tat it works :frowning:

As always, thanks in advance :slight_smile:

Cheers

EDIT: did some more testing… raised all the masses and forces tenfold, just to see if it was a scale problem… no dice, it still does the same…

I noticed that it isn’t so much distance from the origin that might be causing it… it might have to do with acceleration… it seems after some sort of speed barrier is reached, the simulation goes nuts :stuck_out_tongue:

I’m not sure this will help, but try maxing out the solver iteration count to 100, that sometimes helps.

Hmm… Won’t that make everything real slow?

I’ll try it out and see what happens :slight_smile:

EDIT: Just tried it… no go… still shudders and breaks loose after some speed…
(it isn’t even going that fast really…)

More Edit:
I have no idea what is causing this… added a readout for my velocity, so I could see at what speed it died… that’s not consistent either… so strange…

Increasing the masses did make everything feel more realistic though… I’ll keep trying to see if I can figure it out… meanwhile, any input is greatly appreciated :slight_smile:

Just want to add one more observation… what’s really strange is that it’s not the fixed links that are breaking and everything falls apart… the entire simulation freaks out, things start wobbling back and forth, it doesn’t make “physical” sense… it’s not an assembly problem with my setup… it’s something deeper down

Cheers again

Those masses sound pretty low, I’d expect something more in the 1000 range for a 1x1x1 cube.

If it’s some sort of rocket stages detaching, I’d go for a lot simpler method and just unparent them after a fixed time of flight.

It is rocket stages detaching :slight_smile:

If I can’t don anything about the joints… that will be my next move actually… I’ll write my own script to unparent them based on ‘forces’, much like what’s happening here… only manually.

We’ll see how that goes.

Just a follow up, apparently the configuration of the rocket stack does have something to do with it… I changed some elements around, and it seems some colliders just don’t like being near others… I’m using capsule colliders for the lack of cylinder colliders… I tried isolating the cylinder primitive’s mesh to use as a mesh collider, but I can’t get it to stay in my project panel…

I guess I’ll try exporting a cylinder from 3Ds Max or something… I just hate dealing with relative axes and all that… (Max is Z-up)

Cheers

If you try the mesh collider approach you’d have to make each section convex.
Did you try just a stack of cube colliders, since thats the 2nd best precision collider after sphere.

I’m not really sure why, but it appears that when force versus mass gets greater than 10:1, the physics can become unpredictable. As it approaches 100:1 it really gets crazy, particularly with joints. Setting the solver iteration count to its max tends to improve things at the low end of the range, but nothing seems to help for the higher end. The other thing I’ve found is that PhysX colliders don’t tend to rest against each other well at all, no matter what settings I use, and the issue gets worse as speeds increase.

Although I’ve been messing with Unity physics a long time, I certainly don’t consider myself an expert on the subject and I’d love for someone who knows more about this to jump in and show us how it “should” be done.

Well, I got it much better now!!

Swapped out the capsule colliders for cylinders I imported from Max… I didn’t know you could have colliders as children… that was extremely useful :smile:

Apparently cylinders as convex mesh colliders are much more stable than capsules… especially when stacked…

I guess the bottomline is, don’t stack capsules… it doesn’t work in real life, it doesn’t work in PhysX either…
Managed to get up to 25000 meters (units) at about 500m/s… then the fuel ran out… that’s pretty good :slight_smile:

Thanks a million for the help!!! I’ve spent the last 3 days cracking my head over this…

Cheers

EDIT: got to 700m/s in freefall from 30,000m… that’s over Mach 2 :smile: