1
$\begingroup$

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?

enter image description here

enter image description here

$\endgroup$
2
  • $\begingroup$ maybe show us a sketch or a link to an animation how it should look like? $\endgroup$
    – Chris
    Commented Mar 8, 2022 at 16:07
  • $\begingroup$ Thanks Chris. I added a gif to visualize what my node setup does. $\endgroup$
    – Oroko
    Commented Mar 8, 2022 at 18:34

2 Answers 2

2
$\begingroup$

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:

enter image description here

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.

enter image description here

Blender 3.1b. For earlier versions, I think all you have to change is Scene Time to a #frame-driven Value node.

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

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 Sine X along Y Axis Sin(x) along Y axis

In this example I make a cube go along X axis and random Y position every 50 frames. enter image description here

$\endgroup$
1
  • $\begingroup$ 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. $\endgroup$
    – Oroko
    Commented Mar 9, 2022 at 5:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .