Move a bone depending of distance between 2 objects ?

Hello, this is in the title, is it possible (and how) to move or rotate a bone when a object goes far from another object ?
For example, when the two objects are at 1 unit the bone relative angle in X is 0 degree and when them are at 2 units the bone angle move to 45 degrees.

Thanks in advance.

This is possible. Would you want it move immediately to 45 degrees or transition to it the further away the objects get(approaching 2 units)?

This is possible. Would you want it move immediately to 45 degrees or transition to it the further away the objects get(approaching 2 units)?

You’ll want to use a distance driver on the bone to accomplish this. See attached file…

In the attached file there are 2 cubes and one bone. The bone has a driver on it’s z rot. The driver is a distance type driver and its source is the two cubes. Move either cube 1 bu to the left or the right and the bone rotates 45 degrees. The behaviour of the bone rotation depends on how the curve in the graph editor is set up.

Randy

Attachments

example.blend (406 KB)

I used a distance driver combined with an Action Bone constraint. In the action I just keyframed the bone at 0 and 45 degrees.

Attachments

dist_action modifier_test.blend (1.9 MB)

OK, the revolt_randy seems simplier, but thank you both. I understand how it works but, in my model I don’t find how to add a driver, I went to Graph editor, and selected Drivers but there’s nothing, I though I add to first add a F-curves modifier, but all it’s greyed inside.
I tried to find a tutorial but they’re all about shape key. Can you help me ?

It’s ok I found, thank you for your help !