Copy Future/Past Location in Drivers (or Geo Nodes)

Been forever since I’ve been on this forum, may start posting about a big project I’m producing, but I’ll cut to the chase: I’m trying to come up with ways to make my animations considerably easier by automating things. I have it worked out intuitively in my head, but finding ways to accomplish the things in my head with features Blender actually has is another matter.

What I need: a way to get one object or bone to essentially copy the location of another object or bone, but with a differential in the timeline. As if to say “copy location of that object, but copy it’s location where it is five frames ahead (or ago as the case may be).” Almost like an onion skinning-like result, but with actual objects or bones.
I assume I would accomplish this by entering some line of code as a Driver, or possibly using Geometry Nodes as a last resort, but I know little to nothing about Python scripting besides using hashtag to make a Driver and then basic math functions. Aside from the aforementioned, I may need to differentiate the target object’s location in World Space, Local, or relative to a third object (or even it’s nearest verts) depending on what I need for a given animation. I’ll also need a way to adjust how far ahead or behind in the Timeline I want to get the target object’s location from (I could do this using another bone like a slider or a Custom Property as another factor in the original Driver), and preferably not restricted to frame numbers but seconds and fractions or multiples thereof in case I change the frame rate for any animation where I use this system.

I may describe more details as to what things I need this for if that’s helpful but for now I just hope someone can point me in the right direction as far as the code I would need to enter as a Driver to accomplish copying the location of another object but from some offset in the Timeline

1 Like

It’s easy enough if you want to do it once: copy transforms, visual keyframe, clear constraints, move keyframe -5 in x.

If you want to do it continuously, I would duplicate the target object, move its keyframes -5 in X, and copy transforms from it.

I know that’s probably not as dynamic as you might sometimes want. Blender isn’t good at treating things in the time domain like this. There may be a scriptable solution somewhere.

2 Likes

Not sure about future frames, but there is possibility to use drivers to make object and\or bone copy transform with delay, you can set up delay in frames for each channel. Just google “blender delay driver” it must be somewhere there.

1 Like

Quite right, having to move over the transforms for every single bone or object I use this one would deceit the purpose of the “easiness” I am trying to accomplish. But I’m counting on the possibility of scripting it, as long as I can learn how despise my dyslexic pile of brain matter, haha!

Hello !

So already you can forget about geo nodes, because they don’t allow to access time information.
Drivers : it might be a bit limited, what you’re trying to do is more suited to a script.
PyDrivers are kind of an hybrid solution, it’s using a little script as a driver, that might be a good fit.

In a nutshell there are two main approach :
1/ you want realtime feedback : it’s much more tricky and I’ll try to explain why a bit later.
2/ you execute a script that “bakes” the movement, and if you look at similar functionalities in blender, many things work this way, like for instance motion path.

Say we are at frame 1 , and we want to know what is the position of a Cube at frame 10, how can we do ?
A cheap way is to scan it’s motion curve, if the cube is animated . It’s possible to evaluate it’s animation at a given frame , and therefore to know what it’s position will be.
But it’s super limited, because you’ll only get the Fcurves value for it’s position. If the cube has constraints, parents, that are also influencing it’s position you won’t get a correct result.

So in order to get the real position of the cube, the best way is to actually go at frame 10, evaluate the whole scene and go back to frame 0 with the cube’s position.

Maybe there is a way to evaluate position at a time, and skipping evaluating objects that are not relevant to cube’s position. All this append thanks to the dependency graph ( depsgraph) which is supposed to take care of relation between objects and find what to evaluate and in which order.

If there is a possiblity to get cube’s position without changing frame, then it’s by looking at which options the depsgraph provides in python.

Or you do that the old school way by changing frames and it can be simpler but you get the penalty of evaluating the whole scene each time. And depending on how your script/driver will work, this silly operation might append several time if say you use that in different objects.

That’s why baking might be good enough in the end, once it’s baked you get fast feedback, where trying to make it realtime, might induce a big slowdown ironically :smiley:

Hope that helps a bit, I know I didn’t provide solution but you might have a better idea of the problem.

Ah that is indeed a step in the right direction! I found this one: https://blender.stackexchange.com/questions/108373/adding-a-delay-for-a-driver
As you said it is a delay, which indeed is part of what I want to accomplish, but I’m assuming if it’s possible to call upon data further back in the Timeline, the opposite should also be possible. I may try that script out when I get a chance but I will also wait for any more advice more users may have.

1 Like

Ohhh that is interesting. I had assumed it would be better to avoid Baking. But that makes sense and would indeed be problematic because in most if not all cases for the items I will be wanting to target, their location I need to track will be influenced by constraints, parenting, or such.
I’m still not sure how to accomplish either option, however, so if you have any further information or resources to at least point me in the right direction I would be extremely grateful.:blush:

However I just had another thought: part of the functionality I need, is the flexibility to change the original object’s animation, and for its past and future positions to be updated live. But if it were baked, every time I changed the animation, I would have to re-bake, right? Altho as you said that might be quicker anyway. So I may have to seriously consider both alternatives.
But also—just thinking out loud here—if scripting presents the problem of retrieving an object’s location without the influence of constraints and such, wouldn’t it be possible to script those factors into the equation? In a way that would work or account for any situation. I know that might make for greater lag (and greater scripting efforts for me), but again, just thinking out loud.
At any rate, if baking is a better alternative, I am still not sure how to accomplish this.

If you think about it, you can’t accurately predict the future if you add those factors. Here’s a very simple scenario: a cube’s Z rotation is constrained to another object’s location. That’s easy to predict, you can look ahead and get that data. However, the second object also has location constraints- it interpolated between objects 3,4, and 5. Object 3 and 4 are constrained to object 6, and object 5 is constrained to object 7. Your cube z rotation is now dependent on 6 other objects, which have 6 internal relationships. Thus, the z rotation of the cube requires a minimum of 36 calculations per frame. How do you get that information without baking? If even one of those 6 objects changes, all the other animation data for all the other 6 objects changes, and everything you’ve predicted for the future is obsolete. The other problem is… how far up the chain do you go? And this is a simple animation hierarchy- what about an armature with 100 bones and 50 constraints? How could you dynamically predict that without baking?

1 Like

Ah, that makes sense. Point taken. However I still wonder—please don’t take my words as disrespectful or indicating disbelieve, I am merely lacking in finer knowledge of the inner workings here recognize the need to increase my understanding, plus hoping to think outside the box—if calculating a location with so many bone/object relationships is so intensive, how does the original Copy Location constraint work as well as it does? I of course realize what I’m asking is different because if a time differential. But as long as the animation and keyframes are set as they are by the time I press Play, aren’t all animation curves of all objects involved already set as they are?
To be clear, I’m not expecting the actions to move dynamically as I’m manipulating the objects Before setting a keyframes. That can be whacky as all get-out for all I care. What I do hope is that as soon as I set any keyframes set and then press the Space Bar, that the actions will resolve as the animation plays as it is then, at least close to as well as a Copy Location constraint does. Even if it means fooling those certain bones into just thinking they’re on a different frame than they really are.

Again, please take no insult in my questioning. I’m merely trying to learn all the options there may be being as I am lacking in such knowledge at this time.:slightly_smiling_face:

Not to be forgotten is my incessant gratitude for all the input given so far!
Given the chance I will also try implementing the technique @CYNIC78 pointed me toward when I can.

Well, there is addon called animation nodes, I’ve never used it but watching how it works on youtube I can say it’s very powerfull to animate multiple objects with offsets. So you can give a try to it. It’s pretty complex but there are lot of tutorials how to use this addon. Maybe you will find it usefull.

1 Like

Yes animation nodes is the way to go.

For instance, I can define a single action in the NLA editor for an object then delay the same action for its clones, notice how each clone has different colors, so they aren’t just dumb copies, and no baking.

While you can do the same procedurally in geo nodes with indexes, good luck doing that when the movement has 30 different steps with keyframes on different tracks…

Also Animation nodes has direct support for bones and poses

Geo nodes is better at working on meshes, while animation nodes is really for animating stuff mograph style, quickly.

5 Likes

Glad you fellas confirm my suspicions, I was just looking up Animation Nodes last night but didn’t know if it had all I needed or was still usable with latest versions. So thank you for confirming that! It seems like the most concise thing above what I hopped for in my head, as I am very comfortable with Nodes. I’ll give this addon a go!

1 Like

So I’ve been messing with Animation Nodes and, while I’m still trying to look up more tutorials on how to use them, I’m hard pressed to find a way access or manipulate individual bones with them. Is there a way to do that with this addon? If not I know a possible alternative could me to use empties copying the location of the target bones, but I’d like to make sure before I start adding a plethora of empties to each of my animations.
Is it possible that the Rigging Nodes addon is actually what would be able accomplish my goal?

For now we are talking theoretically so depending on what you’re actually trying to do, or the kind of things you plan your tool it might be simpler or more difficult.

There is a ton of rabbit holes when evaluating a scene, to get each objects position. That’s what the dependency graph do. Try to know each relation, and in which order to calculate them.

Recreating a kind of depsgraph is possible, but a huge amount of work.

Best is , if you don’t find alternative is to start looking into python and test a few things. Based on a test scene how many time a frame take to evaluate.
Maybe it’s possible to get a fast bake by hiding temporarily parts of the scene. Or do a cleaver trick to make the bake more responsive.

Or you can start to look into how to access animation at a given frame, then take parenting into account, then constraints and eventually implement the full stuff if everything goes well.

It looks like a great deal of work especially to make things more responsive.

Another trick is to bake like every n frame with stepped interpolation, so you can get a preview result faster… Not great but at least maybe simpler as a first step.

1 Like

here is a very simple example how you can control (in this example rotation) with python expression. It looks pretty “fixed” but you can plugin more input variables, not just x, y, z - basically you can input whatever you want, even objects.

Make sure you set the bones to xyz euler so that the example works:

The nodes setup just copies the rotation from the cube.

copy rot from object

1 Like

Ah so you have to use script to manipulate bones! Thanks, that helps tremendously! the only thing I’m wondering is, instead of using an object outside of the armature like the cube or an empty as an input, is it possible to access another bone’s loc/rot/scale as an input? Perhaps using another Expression node in place of the Object Transforms Input?

Aside from that I found the Delay Action node and the Delay Time node, but I’m not sure which one to use, let alone how or what to connect them to in order to manipulate movement created outside of Animation Nodes.

That pretty much sums up my goals. If I can’t figure out how to do it with nodes, I may have to learn how to program my own methods somehow. Problem is this is just a small part of a bigger project I’m working on, so I’d like to learn the bare minimum I’d need for this desired function without taking too much time away from my the project as a while. Being busy like anyone else it’ll take me long enough to publish it as is.:joy: But maybe I should try to learn Python more comprehensively anyway as I know it will likely be a lifesaver for other aspects I’ll need. I just don’t know what’s the best place to start as far as tutorial series that may target the use cases that may be more immediately applicable in my situations.

1 Like

Animation nodes might be a way to do it,
to learn python this might not be the best starting exercise especially if you’re new to programming.
And remember , going the “bake” road will make your life much much more easier for development.

It might be a bit complicated to start python, it’s not overly complex nonetheless.

Good luck, at least you’ll learn a ton of useful stuff along the way !

1 Like

With good timing some Curtis Holt videos—including a Python crash course and one about Serpens and EasyBPY—showed up in my YouTube recommendations this evening, and I’m feeling like it’s a good entry down the rabbit hole. Nonetheless, as mentioned, it will take me time to learn sufficiently.
Thus my current plan is to start learning with a goal to create functions to meet the ease and effectiveness I desire for a future point, and in the meantime engineer some next-best methods that are reasonably possible for me in Blender until then.
All the same this thread has been immeasurable helpful in at least illuminating me with insight that lead me to that more practical roadmap for this aspect of my project.
Thank you all for your helpful efforts! It is a very fitting re-welcome for me to this forum after about eight (or five) years of inactivity.:joy::grin:

2 Likes