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

Expression Position / Anordnung von vielen Objekten zu einer Form

Community Beginner ,
Dec 18, 2024 Dec 18, 2024

Hallo zusammen, ich bräuchte Hilfe bei der Erstellung einer Expression. Ich habe 35 Objekte, die am Anfang zufällig verteilt sind und am Ende der Animation eine Form ergeben sollen.
Da ich kein Coder bin, kam ich mit den Standard Tutorials zu Random() oder Schieberegler Position verschieben, ... nicht weit. Hat mir jemand von Euch ein paar Tipps vielleicht auch ein Tutorial?

Danke!!

LG

TOPICS
Expressions
368
Translate
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 ,
Dec 18, 2024 Dec 18, 2024

Try this:

 

1 / Place your layers correctly

screenshot_1.png

 

2/ Add this expression to the position property of the layers to animate them randomly.

seedRandom(index, true);

w = sourceRectAtTime().width;
h = sourceRectAtTime().height;
cw = thisComp.width;
ch = thisComp.height;

sx = Math.random() * (cw - w) + w / 2;
sy = Math.random() * (ch - h) + h / 2;
startPos = [sx, sy];

endPos = value;

randomSpeed = Math.random() * 2 + 1;
t = linear(time, 0, randomSpeed, 0, 1);

[
    linear(t, 0, 1, startPos[0], endPos[0]),
    linear(t, 0, 1, startPos[1], endPos[1])
]

 

Namako2014.gif

 

Translate
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
Community Beginner ,
Dec 18, 2024 Dec 18, 2024

Fantastic. Thank you very much. Some objects “run” beyond the comp size. How can I prevent this or specify the max. size? I tried to change the value at (cw - w) + w / 2, but nothing happened. Unfortunately I am not a coder and understand almost nothing of what is written in the code 😕

Translate
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 ,
Dec 18, 2024 Dec 18, 2024

Try this, it should take the layers' scale and anchor point into account:

seedRandom(index, true);

rect = sourceRectAtTime();
scaleFactor = scale / 100;
w = rect.width * scaleFactor[0];
h = rect.height * scaleFactor[1];

cw = thisComp.width;
ch = thisComp.height;

halfW = w / 2;
halfH = h / 2;

sx = Math.random() * (cw - w) + halfW;
sy = Math.random() * (ch - h) + halfH;

scaledAnchor = [
    anchorPoint[0] * scaleFactor[0],
    anchorPoint[1] * scaleFactor[1]
];

startPos = [sx + scaledAnchor[0], sy + scaledAnchor[1]];
endPos = value;

randomSpeed = Math.random() * 2 + 1;
t = Math.min(time / randomSpeed, 1);

linear(t, 0, 1, startPos, endPos);
Translate
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
Community Beginner ,
Dec 19, 2024 Dec 19, 2024
LATEST

Great. Thank you very much!!

Translate
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