I would like to rotate a plane 90 degrees so it stays vertical & then randomize the z axis rotation with a slight rotation of the x and y as well, just need it to stay vertical.
I have tried this, but zero luck, open to any suggestions:
import bpy, random
def set_rnd():
random.seed(random.random())
plane = bpy.data.objects.get("Plane")
z = random.randint(-100,100)
plane.rotation_mode = 'XYZ'
plane.rotation_euler = (0,0,z)
# every frame change, this function is called.
def my_handler(scene):
set_rnd()
bpy.app.handlers.frame_change_pre.append(my_handler)
The thing is, it doesn’t keep the plane vertical, i’m not sure if I am doing something wrong.
You add a plane > Rotate it 90 degrees on the X axis > Scale it along the Z axis(value= 2) > & then randomly rotate it(z axis)
I am trying to convert those steps into python code, with the last step having different values, all while keeping the plane vertical(maybe a little X, Y offsets, not too much)
When I run it on my machine, it keeps it vertical. Therefore, something else is effecting it. Try it on a brand newly opened file, create a plane, then run the script. If you cannot think of anything else, you CAN lock the x and y axis.