0
$\begingroup$

I'm new to Blender (started a week ago) and I need to animate a dynamic system with a spring that deforms according to the relative motion between the mass below and the moving base.

I'm trying to do this using a Driver in the Screw Modifier, but I have no idea how to achieve this kind of motion. Could anyone help me?

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ Hello, maybe use shapekeys to deform a spiral curve? $\endgroup$ Commented Oct 22 at 9:04
  • 2
    $\begingroup$ There are quite a few tutorials about using springs online. This one is good for beginners and uses the Screw modifier. $\endgroup$ Commented Oct 22 at 9:13

1 Answer 1

3
$\begingroup$

I assume you are interested in rigging this spring for animation using manual placement and keyframing of the top "base" and the bottom "weight", not for physics simulation. If so, here's one possible rig. It uses Empty objects and constraints for implementation.

If you are planning to do more of this sort of thing, I highly recommend that you learn how to use armatures. An armature based set-up would be similar in many ways to what I've proposed below, but it's usually easier to organize a single armature (and its "bones") instead of managing a whole collection of empties, plus it would allow much more sophisticated animation, like properly deforming the top end of the spring so it looks like it has a solid connection to the base, shrinking the radius of the spring as it stretches, etc.

Anyway, here's a non-armature rig...

First, rig your spring to stretch vertically to an empty. I assume that the body of your spring is a small mesh circle (highlighted here):

enter image description here

with a Screw modifier having angle=360, iterations=10, and some negative length. I also assume that the axis object is maybe the weight or the base -- whatever was handy.

enter image description here

Start by switching the axis object to an empty positioned at the bottom of the spring. Here, I've done an Add > Empty > Plain Axes, named it "SpringStretch", scaled it down, and moved it along the Z axis to the center of the bottom-most coil of spring. Then, I switched the axis object in the Screw modifier to this "SpringStretch" empty. If it's positioned correctly, nothing should change.

enter image description here

You could add a driver to try to set the Screw length to match the position of the empty, but it's easier to turn on the "Object Screw" checkbox in the Screw modifier. This will cause the screw to stretch down to the axis object instead of using a fixed screw length. When you first turn this on, it'll look ridiculous because it assumes a single iteration should stretch to the specified object, and then it just continues the other 9 iterations at the same length:

enter image description here

So, switch the number of iterations to 1 and increase the angle to 3600 (i.e., 10 complete revolutions). The modifier should look like this:

enter image description here

and the spring should look like it did before:

enter image description here

But, it's now stretching to the empty. If you grab the empty and move it along the Z axis, the spring will stretch to it.

enter image description here

Moving the empty in the XY plane does not work, though. Because the empty is the axis object, it will change the position and radius of the spring in weird ways. We'll fix that later.

Second, let's get the Base and Weight attached. I'm assuming you have SpringTop and SpringBottom "stubs" to visually connect the main Spring to each of these other parts, as in the following picture. Get everything aligned and especially make sure the new SpringStretch empty is placed to line up the Spring with the SpringBottom:

enter image description here

We want the SpringBottom and Weight to move with the SpringStretch empty, so parent both of those meshes to the empty.

We'll also want an anchor point on the base around which the entire Spring can pivot, so create a SpringBase empty inside the base where the spring joins and parent SpringTop, Spring, and the SpringStretch empty to the SpringBase empty, then parent the SpringBase to the Base:

enter image description here

The parenting relationships should look like this:

enter image description here

The purpose of all this is that rotating the SpringBase allows the whole spring to pivot at the base:

enter image description here

while moving the SpringStretch along its local Z axis allows the Spring to stretch in the orientation set by the SpringBase rotation:

enter image description here

Third, we want to rig this so you can control the spring by setting the position of the base and the weight, without manually rotating the SpringBase or setting the position of the SpringStretch. We'll do this with some object constraints.

Make sure the rotation on the SpringBase is reset (i.e., select the SpringBase and hit AltR), and set the SpringStretch along the Z axis to the desired rest length. (It might be a good idea to snap it to the grid or set a round number in the Sidebar > Item > Location > Z settings. I set mine to -3m.)

enter image description here

We're going to set up a control empty for the Weight. Click on the weight, use ShiftS > Cursor to Selected, and then Add > Empty > Sphere, name the empty WeightControl, and size it so it's a little bigger than the weight.

enter image description here

Select the SpringBase empty and go to Properties > Constraints, and add a Damped Track constraint with the WeightControl as the target, and Track Axis=-Z:

enter image description here

Now, if the WeightControl is moved, the spring should pivot to point at it, though it won't stretch yet:

enter image description here

With the WeightControl back at rest position (where the 3D cursor still is), we're going to add one more empty at the center of the weight. Create a new empty at the 3D cursor with Add > Empty > Plain Axes, and name it WeightPosition. Now, do some reparenting: parent the SpringStretch to the WeightPosition and the WeightPosition to the SpringBase.

The new WeightPosition empty should be here:

enter image description here

and the new parenting relationships should look like this. Note that WeightControl isn't parented to anything.

enter image description here

Why did we do this? Well, you'll see that moving the WeightControl still pivots the whole spring to point as before, and we can still move the SpringStretch along its Z axis to stretch the spring. But, we can also move the new WeightPosition control along its Z axis to stretch the spring, and unlike the SpringStretch, the WeightPosition starts at the position of the Weight in rest position.

This last bit is important because we can now use a constraint to move the WeightPosition empty automatically to the position of the WeightControl, as we move it around. Click on the WeightPosition and under Properties > Constraints, add a Copy Location constraint with Target=WeightControl:

enter image description here

Now, wherever we move the WeightControl empty, the spring will pivot and stretch so that the Weight lines up with the position of our WeightControl:

enter image description here

The final result is that both the WeightControl and Base can be moved independently, and the spring will stretch between them:

enter image description here

At this point, it's a good idea to move all the secret mechanisms (SpringBase, SpringStretch, and WeightPosition) to a separate "Mechanisms" collection that you can hide. It also might be a good idea to make the Weight non-selectable in the outliner (see the "Disable Selection" options in this part of the manual), so you don't accidentally select it while trying to select the WeightControl.

My Blend file is attached.

$\endgroup$
1
  • $\begingroup$ I really appreciate your effort in making the tutorial and uploading the file here. The idea behind it is to import data from a simulated system in python and create a cool animation. Thanks! $\endgroup$ Commented Oct 23 at 8:59

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.