• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

move from one random position to another?

Explorer ,
Jun 16, 2017 Jun 16, 2017

Copy link to clipboard

Copied

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!

TOPICS
Expressions

Views

5.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Jun 16, 2017 Jun 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

...

Votes

Translate

Translate
Advisor ,
Jun 16, 2017 Jun 16, 2017

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jun 16, 2017 Jun 16, 2017

Copy link to clipboard

Copied

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]);

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jun 16, 2017 Jun 16, 2017

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 18, 2017 Jun 18, 2017

Copy link to clipboard

Copied

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é

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 20, 2017 Jun 20, 2017

Copy link to clipboard

Copied

Update: @Xavier

The code is doing what I need! Thank you very much for you help.

best, rené

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 30, 2021 Jul 30, 2021

Copy link to clipboard

Copied

LATEST

Hey Xavier, 

 

Where would I enter this expression for it to have an effect on the randomisation of the playback? Can this expression achieve things like this? 

 

https://www.youtube.com/watch?v=0NLLRKGVDl4&ab_channel=MH80

 

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines