Skip to main content
Participant
March 5, 2022
Question

Randomly change position from a given point in composition

  • March 5, 2022
  • 2 replies
  • 292 views

Hi, I have a problem that kind of drives me crazy:

I have around 50 small objects (a ai cut in pieces) in my comp that I want to have move randomly from their given position -- using an expression that i can paste into all the layers -- even better, have the layers follow an expression from a Null.

The challenge is to have them move from their preset position (which I want to define).

 

May be simple, but drives me nuts!

In hope for help,

Chris

This topic has been closed for replies.

2 replies

Mathias Moehl
Community Expert
Community Expert
March 10, 2022

Wiggle could also be an easy solution. Set the frequency to 0, to make sure it is not wiggling at all:

 

This example will move the layers up to 200px in a random direction;

the move starts at 1s and ends at 3s:

 

var amplitude = linear(time,1,3,0,200)
wiggle(0,amplitude)

 

 

 

 

 

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Mylenium
Legend
March 5, 2022

As imple as using a linear interpolator:

 

mPos=thisLayer.transform.position;

mTime=2;

 

seedRandom(index,true);

randX=random(0,500);

randY=random(0,200);

 

X=linear(time,0,mTime,mPos[0],mPos[0]+randX);

Y=linear(time,0,mTime,mPos[1],mPos[1]+randY);

 

[X,Y]

 

This can of course endlessly be modified and expanded upon, but that would require a deeper explanation as to how you actually want it to work rather than such a borad and generic "Can I do this...?" question, in particular when it comes to the specifics of the timing or where you want you layers to end up in the comp.

 

Mylenium

 

chrisbollAuthor
Participant
March 6, 2022

Linear seems to be the solution, thanks a lot!

I'm still struggling with the arrays (all this is still quite new to me although I used to do Flash programming in the good old days) but I understand the concept.

 

Thanks for your help,

Chris