Page 1 of 1

Layer Random Position Every 30 frames

PostPosted: 04/8/2017, 9:22 pm
by alarm
I am trying to have a layer change positions randomly every 30 frames or so. I am having trouble getting the layer to go to a random spot and stay there for 30 frames. My code is:

Code: Select all
if( timeToFrames()%30==0 ){
  x = random()*comp("Comp 1").width;
  y = random()*comp("Comp 1").height;
} else {
  x = transform.position[0];
  y = transform.position[1];
}
[x,y]


This code half works every 30 frames it goes to a random location for one frame and then every other frame it goes back to its original location.

My question is: How come the else statement doesn't hold the layer in its place? It's as if the position of the layer that is being set in the previous frame is ignored? Is there a way to save its location so it holds in the same spot for all 30 frames.

Re: Layer Random Position Every 30 frames

PostPosted: 04/22/2017, 2:20 am
by hans123

Re: Layer Random Position Every 30 frames

PostPosted: 04/24/2017, 12:31 pm
by alarm
Thanks Hans -- I appreciate the help.