-
Playing a layer only when it moves
Hi there, I’m stumped and wondering if anyone has a solution to this.
I’ve got a layer that starts with a single frame of a character standing still, and then plays a really simple walk loop til the end of the clip. I would love to be able to write an expression (or through another method if there’s one I’m not thinking of) that would hold on that still frame when the layer is still, but if I’ve animated the position of the layer, it plays the clip at normal speed, so I get a very quick and easy way to make it look like the character is walking when he’s moving and standing when he’s still.
I can obviously do it by hand by keyframing the timeRemap value, but I would love to automate it because I’m planning on having dozens of these little characters all running around and it’ll get messy fast.
I’ve tried an if/then statement applied to the timeRemap value that compares the position to the position in the previous frame and if it returns that they are the same it sets the timeRemap attribute to 0, but plays the current value of timeRemap if they are not the same, which looked like this (this is just the x values for now to keep it simple):
if (transform.position[1] == transform.position.valueAtTime(time- 1/(thisComp.frameDuration))[1]){
0;
}else{
value;
}When the layer is still, this works to set the timeRemap to 0, but when it is moving it sometimes displays the correct frame, and sometimes jumps to 0. I cant for the life of me figure out why it doesn’t constantly play the correct frame. Anyone have any ideas why? Or maybe another method to try?