I have set up a simple car like model in blender 2.8
I have now set up a rigid body so I can simulate simple physics
- Main Block - Active Rigid Body
- Wheel - Active Rigid Body
- Empty - Rigid Body Constrained
This exactly works as expected. When I set the constraint to Hinge, also the wheels are turning when the vehicle rolls down a test plane)
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....
degrees(15)
or ~860 degrees to your rotation. . Consider adding rigid body "animated" property keyframes of wheels as True at say frames 1 and 49, then off at 50. as in blender.stackexchange.com/questions/5100/… $\endgroup$