# How to connect and control a ragdoll?

I want to evolve walking creatures like this

But you can see cubes are not really following bones and they even fall apart at some point. I connected those cubes through Rigid Body Joint constraints and made them follow bone orientation (cube.worldOrientation = bone.worldOrientation) through python which in turn must be controlled by neural network output but for now they are just controlled by some sinusoidal functions of time. There must definitely better way to do this or at least improve on this.