Stretchy legs and collision

Hello! I am developing a game together with my friends. If you have a 360-pad, you can play it here:

Anyhow, the player controls a walker thing with two legs, and each analog stick controls each leg. Right now, an invisible rigid body is attached via a configurable joint to the body of the walker. This invisible rigid body has the foot attached to it with a hinge joint, allowing it to rotate. The actual leg is purely visual, and is stretched between the foot and the body.

Now, I want the leg to interact with other things in the physics engine. I tried simply attaching colliders to the leg, though that created jerky behaviour. Adding a rigidbody did not help either. I suspect that you must somehow control these colliders with velocities, not simply setting their position depending on the location of the foot.

So, my question is then: How do you construct this kind of legs in a correct way, in order for the legs to work as proper physical entities, and making them stretch nicely?

You want to use rigidbodies (one per independently moving joint) that have isKinematic set to true. These rigidbodies then should be moved during FixedUpdate.

Usually this is enough for most simple collisions, but often the physics engine can’t handle every situation (it is general purpose), so you may have to do sweep tests to see if you will hit something and then do some custom code to handle those situations if the general purpose solution isn’t handling everything for you.