2
$\begingroup$

I would like to have a number of active RB objects set to animation so that they do not fall until their respective animation check-boxes are key-framed off. For a few objects, this can be done manually, one-by-one. My objective is to have perhaps hundreds of such objects with their respective key-frames corresponding to certain actions in the scene. For example, as an animated object gets close to one of the RBs, the RB's animation check-box gets keyed off and the object falls.

Can a driver be used but reacting based on distance from the RB instead of some rectangular coordinate.

Any ideas would be appreciated.

$\endgroup$
1

2 Answers 2

2
$\begingroup$

You can use Deactivation for this instead. Make the rigid body objects that you want to enable sequentially Active with Deactivation and Start deactivated enabled:

enter image description here

The rigid bodies will then start stationary, and only activate if another rigid body comes close to them. Even an animated rigid body can activate them:

$\endgroup$
1
$\begingroup$

using the same method i mentioned in this post: Novel Use of Drivers

You just have to change 1 line of the python code.

line 3 :

driver = obj.rigid_body_constraint.driver_add('enabled')

becomes

driver = obj.rigid_body.driver_add('use_deactivation')

however you might want to change the LOC_Z to LOC_X or LOC_Y to use a different axis

object_name = "Cube"
import bpy
for obj in bpy.data.objects:
    if  object_name+"_cell" in obj.name:
        driver = obj.rigid_body.driver_add('use_deactivation')
        driver.driver.expression="this_obj<mask_obj"
        driver_variable = driver.driver.variables.new()
        driver_variable.name = "this_obj"
        driver_variable.type = 'TRANSFORMS'
        driver_variable.targets[0].transform_type = 'LOC_Z'
        driver_variable.targets[0].id = driver_variable.id_data    
        driver_variable = driver.driver.variables.new()
        driver_variable.name = "mask_obj"
        driver_variable.type = 'TRANSFORMS'
        driver_variable.targets[0].transform_type = 'LOC_Z'
        driver_variable.targets[0].id = bpy.data.objects['mask']  
$\endgroup$

You must log in to answer this question.

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