Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Asteroids-like “Screen Wrap” effect?

  • Asteroids-like “Screen Wrap” effect?

    Posted by Phil Aupperle on April 18, 2016 at 10:35 pm

    I have the “throw” expression on the x position parameter of a layer, and I’m trying to modify it to return to 0 after it goes past a certain point, like the asteroids in Asteroids. AE is fine with this code, but the layer just keeps going off to the right, never to be seen again. What am I missing? Is the value of x not being updated with the current position on every frame, is it not getting reset to 0, or is there a problem with using only one of the values from position?

    Thanks in advance…

    veloc = 300; //horizontal velocity (pixels per second)
    x = position[0];
    if (x > 500) {
    x = 0;
    } else {
    x = position[0] + (time - inPoint) *veloc;
    }
    x

    Kalleheikki Kannisto replied 10 years, 3 months ago 2 Members · 1 Reply
  • 1 Reply
  • Kalleheikki Kannisto

    April 19, 2016 at 2:26 pm

    If you separate dimensions, you can use “x” value only.

    This would be one way to do what you are describing (use for x-position after separating dimensions):

    veloc = 300; //horizontal velocity (pixels per second)
    x = (value+ (time - inPoint) *veloc) % 500

    It works in the positive direction only.

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