Currently Geometry Nodes, like almost everything else in Blender, are evaluated separately for each frame, there's no temporal continuity in a logical sense. You can't easily access a previous position of something, similarly how in a shader you can't easily access a neighboring sample/pixel. You can figure out what's supposed to be there, if you have an access to the logic that draws it. This means for more complex problems you could calculate the object position for each previous frame, with a triangular growth of performance cost, as a 1000 frame long animation would require all 1000 frames to be calculated just on the last frame; average 500 frames calculated per frame. A 2 hours long animation at 60 FPS would increase the average performance cost of the node tree $2 × 3600 ÷ 2 × 60 = 216,000$ times!
Also, quellenform's or my proposed solution above wouldn't be able to calculate positions in cases when they are based on external data like object position.
So what are the alternatives? First is using a driver. However a simple driver won't allow you to read a previous state. What you need is to use Python, and access functionality outside of the whitelisted sandbox set, in order to either:
- at the beginning of evaluation read a state saved earlier, and at the end of evaluation save the final state for the frame;
- at the beginning of evaluation evaluate previous frame and read data from it.
The first of the approaches requires somehow using a driver to store data, which would be unreadable even for driver hacking standards. The alternative still suffers from the triangular growth problem, because it's recursive (not to mention you may run out of memory through a very long recursion).
So rather than using a driver with just a little out-of-sandbox hack to access a previous frame, this ends up to be a complex solution, where you duplicate an attribute array for each frame, deal with a problem that it may have a different length before/after evaluation, deal with the fact your geonodes modifier might be just one of many, deal with caching, but also with a way to allow to refresh the cache... This problem is too complex for drivers, and if you just want to use Python for an iterative animation, here are good starting points:
How to add driver expression result from previous frame to current frames expression (way to compound expression output?)
Distributed interaction visualization
Pin cloth solution
An exception from the stateless nature of Blender, where each but the first frame depends on a previous one, is physics. This solution uses my previous answer where I figured how to dynamically change the PIN group by using geonodes:
Assign vertex group in Geometry Nodes (v3.3)
The idea is simple: based on frame number apply a PIN mask to your vertices - only those vertices will be moved by the cloth modifier, and the rest will stay in place.
Modifier stack: (refer to the linked answer for their settings)
Geonodes Main:
(faces are needed for boolean, but then excess vertices are removed just to end up with a mesh line)
Cloth settings:
Possibly not all of these settings are needed, the idea is that the cloth modifier is not actually supposed to simulate anything - it only keeps the previous positions and updates the positions of the PIN group:
I start the animation and simulation at frame #0, because the vertices start at index 0 and I wanted to keep the node trees simple:
Geonodes Postprocess:
Result