Bone constraints issue. Keep vertical movement

Hi.
I need help to solve a problem. I have a crane rig. The control at the right rotates the arm. The tip is always facing down. The arrow on top moves the arm back and forward.

When I rotate the arm the tip of the crane moves slightly backwards
02

I can adjust it manually using the arrow but I want the arm to adjust automatically to keep a perfect movement up without going backwards. Something like this:
03

I hope I have explained myself well. Any idea? I guess some kind of constraint but not sure how

You could use a Floor constraint to pull the arm out to the control position.
As long as the control bone isn’t parented to the arm, then it won’t be rotated with it, and will keep it’s relative position.

Here’s a mockup:
StretchArm.blend (118.4 KB)

I set a custom shape for the control, and also set the Override Transform. So it would keep the control shape at the end of the arm. even though the control itself is left behind when the arm rotates away from it.

2 Likes

Actually. Floor doesn’t quite work.
As the arm rotates higher, then the angle on the axes stops it from extending as far as it should.

Here’s a version that uses some trig in a driver on a Limit Distance constraint.
StretchArm.blend (120.5 KB)

The controller is more of a target underneath the arm now, rather than moving the tip of the arm. Conceptually, that’s probably not a bad thing, as it’s more of an aiming point for the thing that’s hanging from the end of the arm.

1 Like

Nice solution, it works in your scene. I tried but I can’t make it work in my model since it’s a bit math based and I get lost ( my fault). Anyway thanks for your help :slight_smile:

SOH CAH TOA. :slight_smile:

It’s visualising the problem as a right-angled triangle. There are two dimensions that we know, and one that we want to work out.

We know the angle that the arm is pointing up. We can also get the distance between the target point, and the base of the arm (the ‘Adjacent’).
The value that we need is for the top edge of the triangle (the ‘Hypotenuse’).

So we have the pieces for CAH: cos(angle) = Adjacent / Hypotenuse
Rearranging that, we can get: Hypotenuse = Adjacent / cos(angle)

That’s basically what the driver is doing. I also put the numbers through abs(val), which gets the ‘Absolute’ value for a number. If its value is positive or negative, it will be returned as a positive value.

The other thing to check is which ‘space’ the values are coming from. World, Local, or for the Arm and Target in the driver, ‘Transform’ space. I have them both parented to the same bone, so they live in the same coordinate system.

1 Like

Sincerely thank you for the explanation :slightly_smiling_face:

Ok, I’ll give it another chance, Do not give up!! :sweat_smile: I’ll try and let’s see what happens

Thanks again

1 Like

I guess I’ve been on an IK kick lately. Here’s a different way to do it:

ikstretch.blend (111.2 KB)

ik1 is locked in all axes, parented to control so it inherits control’s rotation, has stretch enabled. ik2 is unlocked, has stretch enabled, has rotation enabled in IK constraint so that it will reach straight down to get the position + rotation of the IK target. Deforming bones-- weight and piston end, which damped tracks the control-- are set to not inherit scale.

Manipulate control and ikt (determines position of the hanging weight along the ground plane.)

2 Likes

If you don’t mind…
tipVertical_test.blend (958.4 KB)
Can you take a look to my file and see what is wrong? It’s not working despite I use the same driver you shared. Maybe I missed anything :frowning:

1 Like

Yours has almost everything working correctly.

The difference is the rest position for the target bone.
In Edit Mode, mine is positioned at the same location as the base of the arm. That way when it moves away, its location offset is being measured from a ‘zero’ location that’s at the arm’s location.

If I do that in your file, then it works as expected.

1 Like

I did make a small change which gets around that requirement. It allows you to Alt-G the target bone, and have it reset to a more sensible default position:
StretchArm.blend (120.3 KB)

That said. The IK solution provided by @bandages looks really good too. It gets around needing to use a driver at all.

1 Like

Thanks both! I’ll try the magpie solution later once I understand everything but by the moment the IK solution is fastest. The magpie’s one is very interesting to investigate a few things about rigging and learn a lot :slight_smile:

1 Like

Yeah. I’ve been rebuilding and playing around with the IK version too.

It’s generally simpler to operate, and (with the right parenting) avoids some issues when you move and rotate the entire rig.

Sorry for coming back with this, but I found a problem since it’s not perfect aligned the rotation axys with the pistonEnd bone in my model… I tried using a damped track constraint to an empty placed at the center of the geometry to make the mesh slide correctly but there is a kind of offset and it doesn’t work correctly.



How would you fix it, please?
test2.blend (1.1 MB)

The bones along the arm aren’t aligned with the point that it’s all rotating around.

I set the Z value of the ik1 tail to same as the head value., then set the cursor to the tail, and snapped the other bones at that end to it. Then I did the same for the head of the bone, and snapped the things at that end to it (including the empty).

If you do this, you’ll need to un-parent the end portion of the arm first, then reparent it afterwards. Otherwise it’ll get shifted out of place when the bones get moved.

test2.blend (300.9 KB)

If necessary, you can move the ‘weight’ bone back up into position. The IK bones are the important ones to keep aligned.

Incidentally. It’s probably best to keep all the ‘moving parts’ within the armature. Adding a new bone instead of using Empties for the other bones to target. It will all work the same, it just keeps things more self-contained.

Also, there are a couple of warnings about invalid drivers (I hadn’t removed them before I uploaded the blend file). It looks like something left over from earlier testing.
In the Driver Editor, you can see all drivers by disabling the ‘Arrow’ icon on the toolbar.
image

[Edit]
Poking at it a little more. When you set the tail position of the ik1 bone. You also need to align the X axis value, as well as the Z. That’s slightly different too, and things wander as the arms gets extended. In Edit Mode, you can set the values for the head and tail positions directly in the Item panel.

Setting the Rotation mode of the Ctrl bone to one of the Euler values (in Pose Mode) will also make using it more predictable.

1 Like

Nice tips, as usual. Just a question: everytime I use damp track and other constraints that depends on another item… should I use bones instead empties?

Thanks again, magpie… if you come to Spain you are invited to a typical Spanish meal xD

I like to keep as much as possible within the armature. Definitely anything that will be keyed during an animation.

Some constraints require separate objects. Things like Spline IK, or Lattices, for example.
But where you just need to track a point, there’s less mode-switching when you add a bone instead of an Empty.

I do like Spanish food. :slight_smile:
Not sure when I’ll next be in the area though.

2 Likes