3
$\begingroup$

What I am trying to do is to move the three bones in the middle in and out, and I can do that right now, but one by one because it's an FK chain

However I want the bone in red to be the controller and move them all and I am not sure how to do this.

arm fully extended

and this is how it should be when it's in

arm fully retracted

$\endgroup$

2 Answers 2

3
$\begingroup$

A pretty easy solution, I think, is this:

  1. Add five bones like this. Name the last one Controller. Unparent Controller

armature consisting of five bones

closeup of relationship properties showing no parent

  1. Rename Bone.003 to IK, go to Pose mode and give it an Inverse Kinematic (IK) constraint with target controller like this:

IK constraint showing Controller bone as target

With the Controller you can move the armature, if it is in pose mode. The IK let's Blender calculate the movement and rotation of the bones automatically. The "4" means, that these number of bones will be included in the calculation. This is counted backwards along the parent chain from the constrained bone (IK). In this case that means all the bones except Controller are included.

  1. give inverse kinematics settings like this to IK, Bone.002 and Bone.001, (all of the target bones of the IK constraint, except the root) setting IK Stretch to 1.0 and locking axis movement. The first makes the bones stretchable rather than fixed length. The second makes it easier for the IK solver to keep their movement in a straight line.

Since none of these bones, nor the controller will be used to directly move the mesh, it's also useful to Clear Deform on them.

Inverse Kinematics settings

Now these bones will become "stretchy" and not have a fixed length anymore. If you move now the controller in pose mode you get:

animation of bone movement

  1. now add 2 bones like this (in Edit mode):

image showing the placement of the two new bones

Because we renamed Bone.003 before these will be called Bone.003 and Bone.004.

We cannot use the "stretchy bones" as deformation bones, because if we would parent them to the object, the object would be scaled too. That's why we add now two bones which "move" with the stretchy bones, but won't be scaled. If we then parent that two added bones to the objects, the objects will just move but not be scaled.

  1. now parent bone to your lowest mesh -> type bone. Parent your 2nd mesh to bone.004. Parent your top mesh to bone.003.

bones and mesh

Enjoy your piston:

Animation of the boxes moving

video tutorial:

https://youtu.be/s-X_Ie9uHGc

$\endgroup$
1
  • 1
    $\begingroup$ There you go Chris. I fixed most of the remaining errors in your explanation; removed an unnecessary step; and made the answer's use of bone names internally consistent. It's close enough to right now to remove my downvote. $\endgroup$ Commented Oct 5, 2021 at 15:12
1
$\begingroup$

There are several ways you might accomplish this. Here's one that I like to use, if the cylinders are to retract at the same time:

  • For my example, I'll only use 2 cylinder movement bones. You should have no trouble adding a third.

  • Create your deformation armature of 3 bones, assigning one bone to each cylinder:

Deformation armature

  • Make sure that each bone is parented to the bone below it, but is disconnected from the bone.

  • Add your controller bone adjacent to the top bone. Parent it to the bottom bone but keep it disconnected. Set it to not be a deforming bone.

Adding the controller bone

  • Make sure its bone roll is zero, because we're going to move it on the Z axis.
  • Enter Pose mode.
  • hover over the Z location value of the controller bone, right click and select Copy as new driver.
  • hover over the Y location value of the top bone, right click and select Paste driver.
  • edit the driver and change the type to Scripted Expression
  • hover over the Y location value of the middle bone, right click and select Paste driver.
  • edit the driver and change the type to Scripted Expression
  • Lock everything but the Z location of the controller bone

location bone with everything but Z location locked

  • Lock everything but the Y location of the top and middle bone

top bone with everything but Y location locked

You can add constraints to the Y locations of the top and middle bone and the Z location of the controller bone, or leave it to the animator to not overdo it.

Why it works

The controller bone is oriented so that it's Z axis is aligned along the axis of the cylinders. By locking it so it only moves along the Z axis, we limit its motion along that line.

The loose bones, on the other hand have their Y axis aligned along the cylinders, so we want the Z axis position of the controller to drive the Y axis position of the other bones.

The driver will cause this to happen in local space, so that the two cylinders will collapse at equal rates. Here's what the driver looks like in the driver editor:

driver

Variations

You can adjust the scripted expressions to handle variations. For example, if the cylinders aren't the same length, you'll have to multiply the Z location by a value to compensate.

Another adjustment might be to change the way the cylinders collapse. Perhaps you want the lower cylinder to close first and then the upper, or the other way around. You do this by modifying the scripted expression, or, if you want more complex motion, by editing the driver curve.

EDIT: It is very straightforward (if you're comfortable with drivers) to modify the drivers so that the controller will collapse the cylinders from either end.

  • Add a root bone.
  • Unparent all of the other bones and parent them to the root.
  • Add a driver to the bottom bone in the same way as the top, middle, and bottom bones were given drivers above.
  • Each driver should have a scripted expression
  • top location if location <=0 else 0
  • middle location if location >= -1 and location <= 1 else -1 if location < 0 else 1
  • bottom location if location >=0 else 0

Now if you move the controller up, the cylinders will collapse from the bottom and if you move it down, they will collapse from the top.

I've left it as an exercise for the interested reader to modify the top and bottom expressions so that the cylinders stop moving when they've fully collapsed. The middle expression is a sort of hint.

Here's my blend file:

$\endgroup$
6
  • 2
    $\begingroup$ +1, but it's always a mystery to me why people use bones at all for non-deforming meshes, where IK chains are not wanted, either? $\endgroup$
    – Robin Betts
    Commented Oct 3, 2021 at 20:14
  • $\begingroup$ This example problem is to small to justify it, but consider a model of a helicopter-thing that can store its blades in its body by folding them against the rotor shaft and then pulling the shaft into the body. As an animator I really don't want to hand animate all that motion when a clever rigger can give me a single control that does all the work for me that I can then quickly turn into an NLA action strip with only a handful of keyframes to raise and lower the blades. $\endgroup$ Commented Oct 3, 2021 at 20:18
  • $\begingroup$ I'm no expert.. I guess you're right.. if the rig involved IK, I would use bones and bone-parenting for something like that but if it didn't, I think I'd just use parenting, constraints, maybe a driver. $\endgroup$
    – Robin Betts
    Commented Oct 3, 2021 at 20:35
  • 1
    $\begingroup$ @RobinBetts thinking about it some more, I think it might be a convenience thing for a lot of animators. If 50%+ of your animation of an object requires you to be in Pose mode with the armature, it's just more convenient to do everything in the armature. That may be why so many face rigs use shape keys but have bones to control the shape keys, for example. $\endgroup$ Commented Oct 3, 2021 at 21:23
  • 1
    $\begingroup$ And when you link a character or a prop into a new scene, you create a proxy of its armature, so controlling everything with armatures and bones becomes essential. $\endgroup$ Commented Oct 4, 2021 at 8:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .