I use a grid to instantiate objects using geometric nodes.
I’d like to rotate them randomly, either 45, 90 or 180 degrees.
So far I’ve managed to rotate them completely randomly but i’d like to add a bit more control and rotate them only with specific values.
Just those values or do you want to rotate in all 8 directions spaced by 45 degrees?
I’m not too sure what you can do with the first one, but with the second, you can use maths to convert a set of numbers to the ones you want. For example, you could pick a random integer between 0 and 7 and multiply by 45. Though note that Blender uses radians so this would not actually work and you would have to convert it at some point.
The random node (with the index) gives a number 0-4, the compare nodes say is this 0, 1, 2, 3 or not and output 1 or 0, then multiply each result by the degrees, then add them all up and convert to radians.
Hum, to radians is a math node and Snap a vector math node
I’m using a early 3.2 alpha version, I’m pretty sure they’re in 3.1, but you already find a solution anyway …
To radians and snap are options in the “math” node (I was using 3.1)
The snap option is in the “vector math” node but to radians is not, you could separate x,y,z and stick a to radians in each channel with a math node then combine x,y,z
You do not have to use vector random or vector math nodes you can do it with normal random and math nodes.
sozap‘s method is simpler if you just want multiples of 45º ( it would give you 0, 45, 90, 135, 180, 225…… etc ). With the method I posted you can choose any specific arbitrary values.
I put 0, 45, 90, 180 but they could be any values like 7, 56, 102 , 105
I think that with the setup you are showing you are entering degree values into the rotation and the rotations will not be correct. Put a math node at the end before the combine x,y,z and set it to “to radians”