0
$\begingroup$

First time asking here!


I have been using Blender for over a year now for: modelling, sculpting, trying out rigging 3D models, and making small animations.

The current piece I am working on has this bunch of worm-like critters, such as:

  1. The worms are extruded cubes with Smooth Shading, as they're to be seen from a distance.

  2. I made wriggly shapes with the Curve Modifier and then saved them as shape keys so they can be reused later (and maybe later exported into Unity).

  3. It's quite a simple motion, but it is supposed to be random and different for each worm, kinda like spooky nasty intestine ascaris lumbricoides.

So how can I make the shape keys:

  1. Randomly switch between each other?

  2. Change values randomly based in the timeline?

P.S.: I was thinking about using drivers or some expression in the Shader Editor, but can't switch Shape Keys from there nor even extract the value from the math nodes into an useful thing for a driver.

P.S.: I have seen this add-on. It gets close to what I am asking for but the values cannot be input-driven, and I have no Python knowledge to edit it, or make a similar script.

$\endgroup$
1

1 Answer 1

0
$\begingroup$

As you already mentioned you can use drivers. Another option is the use of keyframes with a noise modifier.

Example animation:
example animation

In this example the shape keys 1-3 are the thickenings, the rest is for slight bendings. Note that heavy bending does not really work well with shape keys because in-between shapes look deformed/shrunk. That's the nature of the shape keys.
screenshot

Drivers

Drivers can be created and edited directly for the value of the Shape Key. Just enter something like #abs(sin((frame+(pi/2))/5)) in the Value input box. The # tells Blender to create a driver. You only need to add the # character the very first time. If the color changes to purple the driver has been created. The sin() function creates a continuous wave.

There is noise.random() for complete randomness available. If you enter this as a driver expression you will get the error "ERROR: Invalid Python expression...". The reason is that by default Blender automatically disables custom drivers in order to prevent malicious interventions on one’s computer. You will see the error message in the Edit Driver subpanel. Right-click the input box and select Edit Driver to open the subpanel.

In order to allow Blender to compute noise.random() you should :

  • apply the driver. It mentions an error and doesn’t work
  • save the file
  • go to File > Open Recent > your file
  • agree to the security prompt and allow the execution of the script

Click Update Dependencies in the driver subpanel if it doesn’t already work.
(credits to Gorgious who posted the tip about the noise function in the blenderartists.org forum)

Keyframes

First, insert a keyframe. Click the little dot on the right side of the input box, or press I when the mouse pointer is over the input box, or use context menu Insert Keyframe. The input box turns yellow on success. (Later, it can be green when you run the animation.)

Then open the Graph Editor and add a Noise modifier. It's hidden in the N-panel. Adjust the values according to your desires. An additional Step modifier can make the movement appear twitchy.

$\endgroup$
3
  • $\begingroup$ This is very useful, thanks! I do prefer the drivers, so the meshes can be reused in other files without using the graph editor tho. As you mentioned, the mixed shape keys results do get messy and I want to experiment with more extreme bending; do you know if I can activate them one at a time, at random order? $\endgroup$
    – EnkiOH
    Jul 23, 2021 at 21:31
  • $\begingroup$ yes, an armature is probably the better choice for extreme bending. About activation: you can use Python script for the expression and the a if b else c expression works for this. So you can write 0 if frame < 50 else abs(sin((frame+(pi/2))/5)). This would make the animation start at frame 50. Before this the shape key value evaluates to 0. For randomness you can change the numbers for each worm or use the location (location.x). I am not sure if a noise.random() will work because it might evaluated every frame and not only 1x at the start.But you could use a custom property for a random? $\endgroup$
    – Blunder
    Jul 24, 2021 at 16:03
  • $\begingroup$ Python is the way to go, it seems. I will have to study more on the coding and then update on my original question. If anyone needs a similar effect, for the sake of simplicity the best way is what @Blunder listed above. $\endgroup$
    – EnkiOH
    Jul 28, 2021 at 0:33

You must log in to answer this question.

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