# Looping an animated spline trim curve with a small delay for the start in geometry nodes

I'm having trouble looping an animation on a trim curve for a spline with geo nodes. I basically want the end of the trim to go from 1 to 0, then wait (a little delay) for the start to go for 0 to 1, so it looks like a segment is moving. Eventually, I'll apply this for multiple splines all moving at their random speed. (but I think I can manage to do that). I keep trying and no success. I think I don't master math and modulo enough.

Like in this example: https://i.sstatic.net/RBNuf.jpg

• Hello and welcome. Instead of having users go through links and external sites please use the builtin tools to embed images in your post. See How to upload an image to a post? or GIFs Commented Mar 15, 2022 at 22:09
• @DuarteFarrajotaRamos sorry about that, I wanted to post a video and didn’t think the builtin tools would have permit that. Commented Mar 16, 2022 at 0:01

## 2 Answers

with this node setup:

you will get this:

I did a bit commenting about the math in the nodes.

I think the green nodes are easy to understand, the tricky part might be the math. The frame will be divided by 100. So the output of the divide will be 0.01, 0.02, 0.03 and so on. The fraction results just the decimals, so the value will never be 1.01, 1.02 but instead 0.01, 0.02. After that the interval will be extended by 1.3 so i have values now from 0 to 1.3 (ok 1.3 * 0.99 exactly) instead of 0 to 0.99. Then the length of the animated curve will be subtracted to define the start value of the trim curve (which can be from 0 to 1, that's why we subtract that 0.3 again to get the 0 at frame 0 (because we lengthen the interval before by 0.3 by multiplying it with 1.3). Now we just add the 0.3 again (the length of the curve) to set the end value. Easy right? ;)

• Oh wow, I'm not quite sure I understand the idea behind all of the math, but will try to integrate that and create a node group out of it. Thnaks ! Commented Mar 16, 2022 at 12:58

many ways to do it, but to offset in time the 'end' animation just add some value...
is that what you asked?

sorry, had to edit because the image was not clear... here's a little more complex version of same nodes, again it could be done in other ways, maybe show what you already have..? to offset the 'ending' just add some value to 'start' animation, to animate different splines just use their index to add some extra offset... I used a map range node to avoid calculations, but you were using pure math and modulo? may be some some better answers around already, didn't search

• Thanks ! I think I managed to make it loop by inserting a modulo between the map range and the scene time, set to the max + the delay in the add node. Commented Mar 16, 2022 at 12:55
• nice, had that example updated with exactly the same idea Commented Mar 16, 2022 at 13:49