Layer Random Position Every 30 frames
3 posts • Page 1 of 1
Layer Random Position Every 30 frames
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:
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.
- 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.
- alarm
- Posts: 2
- Joined: 06/6/2010, 11:07 am
Re: Layer Random Position Every 30 frames
Hello Alarm,
maybe you find the answer here:
http://www.motionscript.com/expressions ... otion.html
http://www.motionscript.com/mastering-e ... tents.html
Hans
maybe you find the answer here:
http://www.motionscript.com/expressions ... otion.html
http://www.motionscript.com/mastering-e ... tents.html
Hans
- hans123
- Posts: 1095
- Joined: 12/28/2012, 1:37 am
- Location: Paris / France
Re: Layer Random Position Every 30 frames
Thanks Hans -- I appreciate the help.
- alarm
- Posts: 2
- Joined: 06/6/2010, 11:07 am
3 posts • Page 1 of 1