# random transform with for each loop

## Recommended Posts

I have a an object that I cut into pieces with grid. For each pieces, i want to move them randomly within x and z direction. But when I write the @P in Wrangle SOP, it only move the point within that piece. I want to move the whole piece not just a point, how do i do that

randomTransForeach.hipnc

##### Share on other sites

something like this ? you can put in a Multiplier/seed...whatever...up to you.

randomTransForeach_maybe.hipnc

##### Share on other sites

thank you very much, it helps me alot

##### Share on other sites
Posted (edited)

How do you set the values it produce inbetween two values. Let's say between -40 & 40

With this "For-Each connected Piece" all the objects get the same rotation/translate values, I tried to fix it but still no luck.

I spent hours trying to figure it out!

Thx

Edited by klawchi

##### Share on other sites

The rand() function produces a value between 0-1. Knowing this, to set a range, simply use:
[range_start] + rand([seed]) * [range]

In your example, this would be:
-40 + rand(seed) * 80

Make sure your For Loop is running over the correct geometry type (Points/Prims/Count).

##### Share on other sites
11 minutes ago, Fenolis said:

The rand() function produces a value between 0-1. Knowing this, to set a range, simply use:
[range_start] + rand([seed]) * [range]

In your example, this would be:
-40 + rand(seed) * 80

Make sure your For Loop is running over the correct geometry type (Points/Prims/Count).

Thank you so much.

## Create an account

Register a new account