Skip to main content
Participant
Oct 4, 2023 12:43 PM UTC
Question

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

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 is closed to new replies. Start a new post to keep the conversation going.

5 replies

Mylenium
Legend
Oct 4, 2023 2:34 PM UTC

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

 

Translate
Community Expert
Oct 4, 2023 4:46 PM UTC

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.

 

 

Translate
ShiveringCactus
Community Expert
Community Expert
Oct 4, 2023 1:57 PM UTC

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.

Translate
Community Expert
Oct 4, 2023 1:37 PM UTC

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.

Translate
Participating Frequently
Jun 21, 2024 12:22 AM UTC

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?

Translate