Grid Snap Drifting

Combines continuous drift with snapping to a grid.

Code

speed = 10;
angle = 30;
gridSize = 50;
radians = degreesToRadians(angle);
rawPos = [value[0] + Math.cos(radians)*speed*time, value[1] + Math.sin(radians)*speed*time];
[ Math.round(rawPos[0]/gridSize)*gridSize, Math.round(rawPos[1]/gridSize)*gridSize ]
gridsnapdriftpositionanimation

How to Use

Apply to the Position property. The layer drifts at a set angle and speed, then snaps to the nearest point on your chosen grid size.