I try to copy a uvsphere which has basic physics behavior: rigid body, collision mesh. The spheres should just fall down onto a plane.
The code to create the copies is here:
def selectSingleOb(self,name):
ob = bpy.context.scene.objects[name]
bpy.ops.object.select_all(action='DESELECT') # Deselect all objects
bpy.context.view_layer.objects.active = ob # Make the cube the active object
ob.select_set(True)
return ob
def startUp(self,n):
self.nObjects = 3
self.spheres = []
zOffs = 15
sIdx = 0
for i in range(0,self.nObjects):
sphere = self.selectSingleOb("Sphere")
bpy.ops.object.duplicate(linked=False)
newSphere = bpy.context.active_object
self.spheres.append(newSphere)
newSphere.rigid_body.collision_shape = 'MESH'
print(f"newSphare rigidBody collision: {newSphere.rigid_body.collision_shape}")
bpy.ops.transform.translate(value=(0,0,zOffs*sIdx))
sIdx = sIdx + 1
The translate-operation should just ensure, that the sheres fall down one after each other.
Now the strange result is, that the first generated sphere (sphere001) does not fall down from top to bottom, it has a drift to one side. The original sphere and the other copies (sphere003 and sphere003) do behave as expected.
Is anything wrong with the generation of the copies? Are there some data not copied but randomly assigned??
The falling of the sphere is not only unexpected, it is strictly-speaking wrong. I'm not very experienced with physics simulations, so I don't know how to simulate a side motion for a sphere when falling down with blender physics parameters !??
The blender version I'm using is blender-3.2.2-linux-x64 with Ubuntu 20.04.