1
$\begingroup$

Bottom line is that I want to animate a bicycle chain using geometry nodes.

Before geometry nodes, I used an animated empty clamped to the curve.

Currently, I use Curve To Points to set the length of each link, and Instance on Points to draw the links. This is very flexible because links get inserted automatically when the curve changes length, all with the correct rotation.

But how do you make the instances move smoothly across the cyclic curve with geometry nodes?

Ideally, think I would even like to be able to continue using that empty because it was helpful for other animation too...

$\endgroup$
1
  • $\begingroup$ Maybe try something like this? $\endgroup$
    – Jakemoyo
    May 2, 2022 at 11:02

1 Answer 1

4
$\begingroup$

Here is a possible solution:

result

Node Setup

After resampling the curve, every point of the curve is repositioned along the curve using the Sample Curve node:

repositioning the points

The Factor input of this node is clamped to 0 and 1. This means, we have to take care, that every node position is within this range.

This is the calculation of the factor:

calculating the factor

The base position of every point is index / point count. To animate the points, we want to move them between their base position and the position of the next point. This means, we have to add between 0 and 1/point count to the position of every point depending on the Scene Time. The Map Range is optional. It’s used to define how many frames should pass at speed 1 for one complete shift.

Using the segment length instead of point count

If you would like to use the segment length instead of the point count as an input, you could do it like this:

segment length as input

Just as the Curve to Points node, this will round down the segment length,

so that a whole number of samples will fit in each input spline

Finally, the complete bike chain

bike chain

A bike chain consists of two different types of chain links. Thus, we need some adaptions to the node net.

node setup bike chain

On instantiation we use a set of the two chain links and align them to the curve tangent by using Align Euler to Vector.

Instantiation

But this is not enough. As we only move from point to point while having two different object types, this would visually lead to an exchange of the two object types after one animation "step".

To correct this, we have to choose the instances for the points explicitly and swap them on every animation "step". We do this by snapping the output of the Map Range to 1 and adding modulo 2 of it to the point index.

Instance index

$\endgroup$
9
  • $\begingroup$ Nicely solved, I like! +1 $\endgroup$
    – quellenform
    May 2, 2022 at 18:50
  • $\begingroup$ Thank you for this! I'm going to attempt to wrap my head around how to convert this from using the Count option to using the Length option, which I mentioned in my original question... $\endgroup$
    – eobet
    May 3, 2022 at 7:55
  • $\begingroup$ @eobet : count = floor(curve length / segment length); segment length = curve length / count; And you can access the curve length by the node with the same name. $\endgroup$ May 3, 2022 at 21:12
  • $\begingroup$ I added a description for setting this up to my answer $\endgroup$ May 3, 2022 at 21:21
  • $\begingroup$ Thanks for the update! I got it working but with one last caveat: As mentioned, it's a bicycle chain, which means that there are two different links (say a cube and a sphere) which I currently do a "geometry to instance" on and then modulo the instance index with 2... however, with your animation solution it looks weird when it loops, because the cube should be where the sphere is and vice versa... so it's as if the factor needs to go up to 2, but I know it can't... I guess that's outside of the scope of the original question, though, so I'll accept this while I try to figure out a solution. $\endgroup$
    – eobet
    May 4, 2022 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.