Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Position & Speed Expression

  • Position & Speed Expression

    Posted by Goh Shuhui on January 24, 2017 at 12:50 pm

    I would like to create circles at random position with certain speed. However, there’s an error that states the expression result must be of dimension 2, not 1. May I know if there’s any solution to this?

    This is what I’ve typed under Expression Position:
    [random (0,10885), random (0,1361)]
    speed/2

    [random (0,10885), random (0,1361)]
    speed/2

    Goh Shuhui replied 9 years, 8 months ago 2 Members · 5 Replies
  • 5 Replies
  • Kevin Camp

    January 24, 2017 at 4:57 pm

    you might try creating two random positions and have the expression animate between them… try this:

    seedRandom(index, true);
    p1 = random( [0, 0], [10885, 1361] );
    seedRandom(index+100, true);
    p2 = random( [0, 0], [10885, 1361] );
    linear(time-inPoint, inPoint, outPoint, p1, p2)

    it will animate the layer between 2 random positions for the duration of the layer (between the layers in and out points)

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • Kevin Camp

    January 24, 2017 at 5:13 pm

    if you’d rather use a rate (or speed/velocity), then this might work for you:
    maxRate = 100; // value in pixels per second
    seedRandom(index,true);
    p = random( [0, 0], [10885, 1361] );
    v = random( [-maxRate/2, -maxRate/2], [maxRate/2, maxRate/2] );
    p + mul(v, time-inPoint)

    modify the maxRate value to change the range of random velocity.

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • Goh Shuhui

    January 25, 2017 at 9:56 am

    I’ve tried both methods but it only moves on straight/diagonal directions instead of moving at random positions.

  • Kevin Camp

    January 25, 2017 at 10:53 pm

    each circle with either expression would move from one random position to another random position.

    but it sounds like you want it to ‘wiggle’ as it moves?

    try:
    freq = 1; // samples per second
    amount = 500; // value in pixels
    seedRandom( index, true );
    random( [0, 0], [10885, 1361] ) + wiggle( freq, amount )

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • Goh Shuhui

    January 26, 2017 at 6:40 am

    It sort of worked but the random positions went way beyond the composition size (10885px by1361px).

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy