I'm trying to create a game where objects can be dragged, but I'm having trouble with the physics. With rigid bodies that have similar masses, they sometimes push through each other when dragged and cause unwanted movements. Here is a demo.
I'd like to do this using only Unity 3D's built-in physics.
In the demo, you can use the mouse to click and drag objects. The cylinders all have box colliders and masses of 10000. They also have various constraints depending on their orientation (none can rotate, and all are constrained in x or y). The sphere has a mass of 1, a sphere collider and a z constraint.
The sphere and cylinders interact well. However dragging the cylinders across one another causes intersection. I do not want this!
The cylinders have interpolate set to 'Interpolate' and collision detection set to 'Continuous'. I have thrown the 'DontGoThroughThings' script onto all the cylinders, but it doesn't seem to do anything. As for setting the velocity of the rigidbodies, I have used both of these following lines with basically the same result:
rb.AddForce(speed * diff * Time.deltaTime - rb.velocity, ForceMode.VelocityChange);
//rb.velocity = speed * diff * Time.deltaTime;
Without writing my own collision detection code, I'm out of ideas. Is there a simple setting or something I've missed?
With the context explained, here's a more precise question: "How can I get the cylinders in my demo to not move through each other?"