Hi - I have 4 cubes added to my scene. They are added as objects and not instantiated on the fly.
I want to randomly rotate, tilt them a bit to make it look more real… How can I rotate all of them randomly on their y axis ? Also do I have to attach a script to all of them ?
Thanks
You could attach 1 script (anywhere in the game) that references them to move them.
Or you could have 1 per object that does the same (but just references its own gameobject rather than the list of 4).
Elaborate on your question if there are specifics you’re looking to know/learn (random value, rotating in general, etc…)
Thank you. Let me elaborate.
My 3d cube Game object names and the desired rotations on y axis are as follows:
A0 : 10 degrees
A1 : 17 degrees
A2 : 4 degrees
A3 : -5 degrees
A4 : 2 degrees
A5: -15 degrees
A6 : 0 degrees
B0 : 12 degrees
B1 : 8 degrees
B2…
B3…
B4…
B5…
B6…
That’s more than 4 cubes, but that’s a bit beside the point. That wasn’t really elaborated. I asked if you needed help with getting random numbers or rotating or anything else? 
int rot = Random.range(0,360);
transform.rotation = Quaternion.Euler(0,rot,0);
That could rotate a cube (or with a slight modification), rotate a game object from a list…
Oops my subject said 40 cubes but when I typed in the description it became 4. The line below is what I was looking for. Thanks
3.transform.rotation = Quaternion.Euler(0,rot,0);
No problem.
and with regard to 4 or 40, doesn’t matter to me (or that line of code), in this sense 