# I have set up a simple car like model in blender 2.8

[![enter image description here][1]][1]


## I have now set up a rigid body so I can simulate simple physics

 1. Main Block - Active Rigid Body
 2. Wheel - Active Rigid Body
 3. Empty - Rigid Body Constrained

[![enter image description here][2]][2]

This exactly works as expected until now.....

## But I need to control the vehicle via a python script (Apply a rotation/force to the 4 wheels)

Therefore I've set up the following script

    import bpy, time
    
    # get the 4 wheels
    wheels = [bpy.data.objects['WheelFrontLeft'], 
        bpy.data.objects['WheelBackLeft'], 
        bpy.data.objects['WheelBackRight'], 
        bpy.data.objects['WheelFrontRight']]
    
    for wheel in wheels: 
        wheel.animation_data_clear() # clear keyframes
        wheel.rotation_euler[1] = 0 # reset rotation
    
    for i in range(1,50): # step through 50 frames
        bpy.context.scene.frame_set(i)
        for wheel in wheels: # iterate wheels
            wheel.rotation_euler[1] += 15 # rotate +15 
            wheel.keyframe_insert(data_path="rotation_euler", frame=i) # insert keyframe

Unfortunately this does not change anything...

After running the script I got a totally messed up scene (everything is wrong positioned/rotated) and if I restart the animation, the vehicle just keeps falling (Only the Rigid body simulation applies without the rotation)

So I don't see any rotation at all. Only when I'm checking the animation checkbox (for the active rigid body wheels), the wheels are moving. In that case the car is not falling anymore (physics won't be applied).
Obviously that is an either or switch for physics/animation

I also tried setting the empty constraint type to **Motor** instead of **Fixed** but then it just falls apart.... 

Also rotating the constraints does not help at all....

## What am I doing wrong? How can I fix this?

  [1]: https://i.sstatic.net/5eylC.png
  [2]: https://i.sstatic.net/ZKYAm.jpg