Physics shenanigans in simulation

Hi all,

I am trying to simulate the run of a fish packer, that is fish spawn, go along a path to a certain bin which then dumps them into a box which runs along a conveyor. This is all supposed to be as realistic as possible, as the aim is to simulate how the machine works in real life. Now, a problem I am having are the boxes, or how the fish and box interact with one another when colliding.

The fish contain a few bones with configurable joints and rigidbodies. Collision detection is set to Continuous and is using gravity.

The box is put together with a box collider on each of the faces, so 5 total with a couple of capsule colliders at the front two corners to help with collision when taking a turn in the conveyor. A box has a rigidbody, mass set to 0.3 (this is crucial as this is what the box weighs in real life, 0.3 kg), uses gravity and is set to Continuous collision detection.

The problem I am facing, is that when the fish (can be between 1 - 4 of them at the same time) hit the box, it causes an incredible amount of jitter, with some of the fish clipping and going partially through the box, which in turn make both the box and fish go all over the place. I can partially fix that by changing some of the values in the physics manager and that will make the fish kind of stay in the box initially but as soon as the box hits something which is inevitable, the fish clip through and ruin the simulation.

This will not happen nearly as often(maybe 5% of the time max) when the weight of the boxes is set to 2, and never if the weight is set to 5. It is worth noting that the combined mass of the fish varies between 3 - 6. But even with the mass of the box set higher, the fish will still behave oddly in the box, small jitters and when the box gets stuck or something the fish has the tendencies to want to go forward and jitter even worse.

I have attached a screenshot of how it looks when the fish clip the box and also my current physics settings. Any help regarding this problem would be greatly appreciated .



First of all I want you to understand you can’t have any illusions of that the physics system simulates real physics. So just because a box has a certain weight in real life does not mean you need to set it to that weight. This is a game engine and the physics are just supposed to look somewhat realistic while being fast, it doesn’t simulate real physics.

I would probably use some triggers that puts the fishes to rest inside the box when they entered the box or something like that and then activate their physics when you need them to. I think the physics system just isn’t accurrate enough to have moving colliders inside moving boxes without some chaos, which I assumed is what you’re doing?

I really can’t tell much from your pictures. The collider outlines look very strange. Or maybe the lines are something else.

So how do the colliders for the fishes and the box actually look?

Yeah, of course :), just want the most accurate results which most closely resemble real life. I would think that that would be the case if the mass of all objects would be the same as in real life to keep the weight ratio between them the same.

And yes, I am trying to move the boxes with the fish in them at the same time.
I did try to do something along the lines of disabling the physics of the fish after collision, disabling the joints etc. It always gave me undesirable results, with the fish greatly changing position and/or popping out of the box. Not sure if it was just something wrong with my code which I deleted unfortunately, but maybe worth another try. No idea what to try other then what I did the last time though.

What you are seeing are not the fish colliders, it is simply a canvas element meant to display weight and length of the fish for keeping track. But I have attached photos of both the fish and box colliders. The box collider within the box that fills the center is a trigger that parents the box to the fish.



I think you should just be able to disable the rigidbodies on the fish without there being any popping? Something like rigidbody.detectionCollisions = false; and then just parent the fishes to the box.

The problem with that is that it won’t let me do that as the joints depend on the rigidbody :/, and messing with them screws this up.