Skip to main content
Participant
October 4, 2023
Question

How would I make a layer wrap around the other side like Pac-Man?

  • October 4, 2023
  • 3 replies
  • 1063 views

I want a layer (several layers actually) to move around in a direction (anywhere from 0 to 360 degrees), once it reaches outside the camera view, it will wrap around to the otherside. Remember in Pac-Man when you go all the way to the right side of screen, you come out the left? That's what I'm talking about. 

How can I write an expression to something move, even diagonally, and have it wrap around once it goes outside view and to keep doing this over for 10+ mins? 

 

 

This topic has been closed for replies.

3 replies

Mylenium
Legend
October 4, 2023

You can add simple modulus expressions to reset the positions every time they reach a certain value:

 

mPad= 50; //invisible padding

mX=thisLayer.transform.position[0];

mY=thisLayer.transform.position[1];

cX=thisComp.width;

cY=thisComp.height;

 

fX=linear(mX%cX,0,cX,-mPad,cX+mPad);

fY=linear(mY%cY,0,cY,-mPad,cY+mPad);

 

[fX,fY]

 

Mylenium

 

Community Expert
October 4, 2023

If you have keyframes that you want to cycle through, all you have to do is add

loopOut("cycle")

to the property. If the animation is simple, this is an easier solution than Time Remapping.

 

 

ShiveringCactus
Community Expert
Community Expert
October 4, 2023

I think the Offset effect can achieve this.  You'd animate the Shift Center To property instead of the layer's position, but I think it's the simplest way to do this.

Community Expert
October 4, 2023

The easiest way to accomplish this is to animate your layer from one side of the screen to the other, starting with the layer's in-point. Trim the layer as soon as the animation leaves the other side of the screen. Now, Pre-compose the layer, moving all attributes to the new comp and trimming the comp to the layer duration. Next, apply Time Remapping, use the K key to move to the last time remapping keyframe, then move back one frame (Ctrl/Cmnd + back arrow), set a new Time remapping keyframe at the start of the last frame, then select the last keyframe and delete it. Now add a simple loopOut() expression to time remapping.

 

You can now extend the outpoint of the Pre-composed (nested) comp, and the layer will loop as long as you want it to loop. You can also change the speed of the move by simply sliding the last keyframe to the left or right without worrying about jerky motion or duplicate frames.

Participating Frequently
June 21, 2024

Help. I want the opposite thing. Suddenly when I move a later off the layer boundry on one side it appears on the opposite side exactly like the OP is wanting to happen. I do not want this. What is happening?