Changing position based on last frame position

   1884   3   0
User Avatar
Member
3 posts
Joined: Oct. 2023
Offline
0

I am trying to procedurally animate things in Houdini, using similar logic as in Unity, moving the object based on its position from last update, i.e., NewPosition = OldPosition + Direction * Coefficient. (The direction vector uses a sequence of weighted input so it's really hard to convert the entire thing into integral)

Using the Vex code below inspired by this post:

vector @posRecord[];
// ... 
if (@Frame == 1)
{
    @P = {0, 0, 0};
}
else
{
    vector lastPos = @posRecord[len(@posRecord) - 1]; 
    v@lastRead = lastPos; 
    @P = lastPos + @N * 10; // @N as direction 
}

append(@posRecord, @P);
if (len(@posRecord) > 10)
    removeindex(@posRecord, 0);

I am able to record the position, but `lastPos` cannot properly read from `@posRecord`. In Geometry Spreadsheet `lastPos` keeps being 0. As a result, the object is merely reading the `@N` as XYZ positions instead of move based on `@N`.

What is going and is there a way to fix this?
User Avatar
Member
9379 posts
Joined: July 2007
Offline
You need to be in a simulation environment to be able to feed back attribute values between frames

Like inside of Solver SOP or inside of DOPnet directly
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
313 posts
Joined: Oct. 2016
Offline
I’m not sure what you are doing but maybe you can copy the value to some extra attribute. Then read it before you change it. No?

It is like monitoring if a file has changed by storing the latest timestamp in a separate variable, then you can see the difference.
Edited by SWest - Oct. 12, 2023 14:10:46
Interested in character concepts, modeling, rigging, and animation. Related tool dev with Py and VEX.
User Avatar
Member
8177 posts
Joined: Sept. 2011
Offline
tamte
You need to be in a simulation environment to be able to feed back attribute values between frames

Like inside of Solver SOP or inside of DOPnet directly

You could use forloop with feedback and animate the number of iterations with the frame number, but you might cook all of the iterations each frame. I'm not sure if it caches the last step or not.
  • Quick Links