# Enabling rigid body physics on an object through Animation Nodes

I'm trying to use the Animation Nodes add-on to animate a practically infinite stream of envelopes falling into a (transparent) ballot box. I want one envelope to appear above the box every n frames, hang mid-air for a few frames, then fall through the hole into the pile of already generated envelopes. I need the physics simulator to handle the collisions.

What I'm currently doing is this: use an object instancer to create the envelopes, then divide time into periods so that envelope i becomes visible at period i. At period i + 10 frames, I then use a Python script to turn object.rigid_body.enabled to true.

That last part doesn't work however: the physics never get computed for the duplicated envelopes. I'm guessing maybe this is because I'm changing the "dynamic" property through a script instead of keyframing it. However I don't know how to generate the keyframes I need through AN (or through a script connected to AN).

Here's my node setup:

The enable_physics script:

import bpy
object.rigid_body.enabled = enable
object.rigid_body.kinematic = enable


("Dynamic" is keyframed on this picture, but it's only for testing purposes on the parent object.)

• The solution to this question seems to solve your problem as well. But additionally I had to to disable the kinematic line in the script (or use object.rigid_body.kinematic = not enable). HTH – binweg Feb 7 '17 at 8:16
• Thanks! I ended up doing things differently however, without Animation Nodes - with a script to duplicate everything and change settings and animations programmatically. I'll post an answer there as soon as I've got time. – Pikrass Feb 10 '17 at 21:34