ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

ping pong

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Marten Kopp
ping pong
on Mar 21, 2011 at 11:09:53 am

Hi guys,

I am trying to make a animation based on the old ping-pong game. I want to use an expression that sent the cube up and down.

The cube moves from left to right, back to the left and again to the right but at that point it doesn't remember it is supposed to bounce back again.

Anyone know some solutions?

sp = 500;
xPos = time *sp;

if (xPos >thisComp.width){
xPos = time * -sp+(thisComp.width*2);}

if (xPos <(thisComp.width-thisComp.width)){
xPos = time * sp-+(thisComp.width*2);}


Return to posts index

Dan Ebberts
Re: ping pong
on Mar 21, 2011 at 4:19:38 pm

Like this, I think:

sp = 500;

totalDist = time *sp;
numCompleteTrips = Math.floor(totalDist/thisComp.width);
thisTrip = totalDist%thisComp.width;
goingLeft = numCompleteTrips%2;
[goingLeft ? thisComp.width - thisTrip : thisTrip, value[1]]g


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 All Rights Reserved