Skip to main content
TheYates
Known Participant
October 24, 2021
Question

Trigger "position" with markers

  • October 24, 2021
  • 2 replies
  • 185 views

Hello, I want to animate "position" of an item. I want that the marker's comment (which will be a number) to add or subtract from the previous keyframe value and place and new keyframe under the marker.

Example; the first keyframe (marker, Y Position) is 50, which I initially set. I want the second keyframe value to be the second marker's comment plus the previous keyframe's second value (Y Position) which is 50 so the second keyframe will be 5 0+ 150 = 200. And the third keyframe will be 200 + 30 = 230 etc.

 

Any help? 

Thanks

This topic has been closed for replies.

2 replies

Meng Zhiqun
Inspiring
October 30, 2021

You can try this. Put this expression in the position.  Hope this helps!

var aniTime = 10/30;// Change this to change the timing it takes to go up/down.

n = 0;

if (marker.numKeys > 0) {

n = marker.nearestKey(time).index;

if (marker.key(n).time > time) {

n--;

}

}

if (n == 0) {

	var y = value[1];

}else{

	var y = value[1] + linear(time, marker.key(n).time, marker.key(n).time+ aniTime, newY().split(",")[0] , newY().split(",")[1] );

}

function newY(){

	var curYVal = 0;

	var newYVal = 0;

	var target = thisLayer;

	var tNumKeys = target.marker.numKeys;

	if (tNumKeys > 0) {

		for (var i=1;i<=tNumKeys;i++){

			var curKey = target.marker.key(i);

			if (curKey.time <= time) {

				newYVal+= Number(curKey.comment);

				try{

					curYVal+= Number(target.marker.key(i-1).comment);

				}catch(e){

					curYVal = 0;

				}

			}

		}

	}

	return curYVal + "," + newYVal;

}

var x = value[0];

[x,y];
Mylenium
Legend
October 25, 2021