Set random rotation and follow by axis

I need a simple script which will randomly set the rotation of the plane and then the plane will follow the local x axis

always true- python module- scriptname.move_obj

import random
import math

def rotate_obj(cont):
    
    own = cont.owner
    
    min = 0
    max = 359
    
    ori = own.worldOrientation.to_euler()
    
    ori.x = math.radians(random.uniform(min,max))
    ori.y = math.radians(random.uniform(min,max))
    ori.z = math.radians(random.uniform(min,max)) 
    
    own.worldOrientation = ori


def move_obj(cont):  
    
    own = cont.owner
    
    if not 'set_random' in own:  
        rotate_obj(cont)
        own['set_random'] = True
    
    own.worldLinearVelocity = [0.5,0,0]  

velocity needs the object be dynamic, on static it won’t work, use applyMovent() for static objects, Change worldLinearVelocity to localLinearVelocity if you want the object to move at his own x axis instead of the world x axis.

thank you very much for the script. The script is helpful :wink: