setting physics properties on a big set of objects

I imported a big set of objects into Blender, that should all act as Rigid Body Game Objects in the BGE. As they are too many to manually change the Physics Type on every single one of them, I am looking for ways to set them all at once.

  • Multi-selection does not help. Only the leading selection object is set.
  • Joining does not help, as the joined objects behave then as one “combined” game object
  • So I’ve been trying to do it with Python.

This is not working with bullet physics yet.
Under which circumstances is this command supposed to work?

  • Problem is that the bge module seems only available when the Game Engine is running, is that correct? So I can’t set this property in the normal blender env, by simply running a script in the text editor?
  • I tried to set the property via controller in this way with the controller modu
from bge import logic
def Player():
    cont = logic.getCurrentController()
    obj = cont.owner
    print(obj)
    obj.enableRigidBody()

whereas the print output shows up, the RigidBody command doesn’t seem to do anything. ( I also find it strange that Game Object properties such as Rigid Body type should be set within the game)

I am pretty stuck now and would highly appreciate any help on this.

I have can’t test this at the moment, and it might screw up some of the other properties of your objects, but it’s worth a shot. so make sure none of the objects are touching eachother, and then select all of them. press ctrl+j to join them all into one massive object. Then, apply the physics settings to the big object. After that is done, go into edit mode, select all, and press p to seperate, and select ‘seperate parts’ or something. Or you could make a bpy script to do what you want, and then run it in the editor.

Hi cswita

thanks for your helpful post. put me on the right track

I am now using the following code:


import bpy
for i in bpy.data.objects:
    if i.name.startswith("Mesh"):
        i.game.physics_type = 'RIGID_BODY'
        i.game.use_collision_bounds = True
        i.game.collision_bounds_type = 'CONVEX_HULL'
        i.game.mass = 0.1
        i.game.rotation_damping = 0.99
        i.game.damping= 0.4
        i.game.form_factor =0.4