ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Position & Speed Expression

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Goh Shuhui
Position & Speed Expression
on Jan 24, 2017 at 12:50:02 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


Return to posts index

Kevin Camp
Re: Position & Speed Expression
on Jan 24, 2017 at 4:57: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


Return to posts index

Kevin Camp
Re: Position & Speed Expression
on Jan 24, 2017 at 5:13:40 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


Return to posts index


Goh Shuhui
Re: Position & Speed Expression
on Jan 25, 2017 at 9:56:03 am

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


Return to posts index

Kevin Camp
Re: Position & Speed Expression
on Jan 25, 2017 at 10:53:17 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


Return to posts index

Goh Shuhui
Re: Position & Speed Expression
on Jan 26, 2017 at 6:40:34 am

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


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]