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$
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$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.