Skip to main content
Known Participant
June 16, 2017
Answered

move from one random position to another?

  • June 16, 2017
  • 3 replies
  • 5298 views

Hi,

this is probably simple for someone who knows how to write expressions better then I do. (I hardly do).

I want a Textobject to move from one keyframe to another. Both keyframes should get a random value. (first keyframe-Position somewhere in the upper part of the comp; second key-position somewhere in the lower part of the komp).


Please help. Thanks!

This topic has been closed for replies.
Correct answer UQg

Maybe this works for you :

if (numKeys<2){value;}else{

    t1 = key(1).time;

    t2 = key(2).time;

    seedRandom(index*1000+1, true); x1 = random(0, thisComp.width); y1 = random(0, thisComp.height*0.5);

    seedRandom(index*1000+3, true); x2 = random(0, thisComp.width); y2 = random(thisComp.height*0.5, thisComp.height);

    linear(time, t1, t2, [x1, y1], [x2, y2]);

    };

But if you have many layers to animate that way, it's probably easier to use markers (either comp markers or markers on a controller layer) to mark the start and end time of the animation, rather than keyframes.

Xavier

3 replies

UQg
UQgCorrect answer
Legend
June 16, 2017

Maybe this works for you :

if (numKeys<2){value;}else{

    t1 = key(1).time;

    t2 = key(2).time;

    seedRandom(index*1000+1, true); x1 = random(0, thisComp.width); y1 = random(0, thisComp.height*0.5);

    seedRandom(index*1000+3, true); x2 = random(0, thisComp.width); y2 = random(thisComp.height*0.5, thisComp.height);

    linear(time, t1, t2, [x1, y1], [x2, y2]);

    };

But if you have many layers to animate that way, it's probably easier to use markers (either comp markers or markers on a controller layer) to mark the start and end time of the animation, rather than keyframes.

Xavier

Known Participant
June 19, 2017

Hi all,

I will try it out.

Would Marker work on each layer separatly (like keyframes). The layers don't start at the same time and don't have the same duration.

best, rené

Mike_Abbott
Legend
June 16, 2017

Maybe you mean 'frame' not keyframe? If so try this on the position property:

if(timeToFrames()%2 == 0){

random([0,0],[thisComp.width,thisComp.height/2]);

}else{

random([0,thisComp.height/2],[thisComp.width,thisComp.height]);

}

Mike_Abbott
Legend
June 16, 2017

I'm a little confused as to what you want. If you are keyframing the text object, as you state, you don't need an expression. Just position your object 'randomly' - where you want it ; ) - and set the keyframe to 'hold'. Right click on the keyframe > toggle hold keyframe.

If you want something else, please clarify.