Accessing position at previous frame? (Motionbuilder)

Can I access data from the previous frame?

I’d like to set up a constraint where object A’s
speed depends on the distance between two other
objects (B and C).

If the distance between B and C is 0 then A does not
move forward. If the B-C distance is 1m then A moves
forward with the speed of 1m/s, if 2m then its 2m/s
and so on.

I figured I’d need to know the B-C distance in the
previous frame in order to decide if I need to change
the speed of A but I haven’t found a way to store a
value between frames.

How is object A being moved?

If it’s with a vector in the relation constraint, you can measure the distance between B’s and C’s vectors which you can then use to push A in a specific direction.

Since what you’re looking for is the total distance between two objects to give you the speed, or acceleration, of the object… you don’t necessarily need the translation in the previous frame. This is depending on how A is controlled, however.

I could multiply the local time with the BC distance and use that to
derive a new position for object A in every frame, however that will
always be based on the original location of A and not the location
from the previous frame.

So if in the 100th second the BC distance is currently 2 meters then
the position of A will be 200 meters from it’s unconstrained position.
No history of earlier BC distances is stored in any form. There is no
difference between BC being 0 during the first 99 seconds and being
2 meters all the time.

Maybe scripting is more fit for this kinda stuff…

Yeah I needed this in the past as well and did not find an easy answer for it, really wanted a framecache node from maya. You might be able to do it in the expression node instead of relations but I ran out research time.

Sorry I don’t have a better answer for you, the other option is to use a python script to post process the animation and update the node , not sure if you can do this at plot…hmm drat I have been so short on experimenting time lately.

Thanks Brad, don’t worry about it, a script was what I really needed.
Relying on previous frames would have made scrubbing backwards
slowish so processing stuff onto a new anim layer is better workflow.