2
$\begingroup$

I'm scripting this file that generates an environment containing objects of different masses, shapes, sizes and physics types. I'm having trouble setting the mass, though...

e.g.

bpy.ops.mesh.primitive_plane_add(location=(0,0,-20))
plane = bpy.data.objects["Plane"]   
plane.scale=((200,200,200))
plane.game.physics_type = 'STATIC'
plane.static.mass = 20

^^^plane.static.mass doesn't work and neither does plane.mass. How do I do this/get it to also work for rigid body and soft body objects?

$\endgroup$

1 Answer 1

4
$\begingroup$

You need to find the right path to the data you are looking for, using the python tooltips in blender can help here, they are enabled by default but if they have been turned off you can enable them in preferences. Searching through blenders python api online can also help.

First let's clarify your use case, you are setting plane.game.physics_type so you may want to set the matching plane.game.mass both of which are only relevant for the game engine physics.

enter image description here

If you are using the interactive physics available in the 3Dviewport then you will want to use plane.rigid_body.type and plane.rigid_body.mass

enter image description here

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .