# Geometry Nodes: How to randomly set Y-Position when wrapping X-Position

I am trying to move instances on points along the X-axis for an animation. When an instance reaches a certain X-value (e.g. 2) it is wrapped to a lower value (-2).

This works just fine but I also want the Y-value to be randomly set i a given range (-1 to 1) each time the instance is wrapped.

The Y-value is set randomly the first time the instance "jumps" back but then remains the same...

Any ideas?  • maybe show us a sketch or a link to an animation how it should look like? Mar 8, 2022 at 16:07
• Thanks Chris. I added a gif to visualize what my node setup does. Mar 8, 2022 at 18:34

You can keep track of which cycle the points are currently in, and use that to seed a random Y. This group allows you to set Max and Min X and Y, the speed of travel, and the density of points: The green node is the 'total' X position of each point, before wrapping. (The red node).

If the minimum X is subtracted from the X total, then it is divided by the X range, and the floor is taken of that (blue node), we have the number of the wrap-cycle the point is currently travelling through. That can be used to seed an random-number-per-cycle, which, in turn, sets Y.  Blender 3.1b. For earlier versions, I think all you have to change is Scene Time to a #frame-driven Value node.

• Thank you so much! Just downloaded your blend-file. After the change from "Scene Time" to "#frame"-Value node it worked like a charm! Mar 9, 2022 at 5:45

You can use trigonometric functions as pseudo random like sine functions.

-1 ≥ sin A ≤ 1

sin 1.57079633 = 1

So we can make random value from #frame Sin(x) along Y axis

In this example I make a cube go along X axis and random Y position every 50 frames. • This actually did not help. The use of sine values resulted in a repetitive pattern when instancing several objects. Even if offsetting the initial values. Mar 9, 2022 at 5:41