I try to simulate dynamic behavior in blender using physics for rigid bodies. Some objects should fall down onto a moving plane.
(there is a previous question related to that: animation locations with python but the positions seems just to scratch the surface of the problem).
I would like to animate the plane depending on the falling objects positions, so that they interact with the falling objects (e.g. do rotations of the plane). But I would like to set coordinates dynamically while running the simulation (running the animation here means: counting scene.current_frame manually).
One aspect of the simulation works fine: if I increment the current_frame, the objects with rigid_body = active do fall down. But changes in rotations of the plane seem to be not recognized. A bpy.ops.transform.rotate(value=2,orient_axis = "X") seems not to be recognized during the animation.
Is there a way to consistently implement dynamical changes of the environment while stepping through the frames (without adding keyframes for the dynmaically changing rotation and position of the plane, ) so that they dynamically interact with the rigid_bodies?
The planes physics property is set to passive rigid_body.
Please run the script, which starts a frame_handler. Then start the animation (from frame 1 to 100). In frame 10 the cup is turned upside down from the script. this is visible in the viewport, but the sphere still seems to falls into the original (unrotated) cup. So the physics calculation does not seem to recognize the rotation, althought the viewport does.
So how can I inform/adapt the environment, on which the physics calculations rely about/to the changes in the cup rotation?
-> edit: one additional thought after experimenting with the physics parameters: if I also set the cup as an active rigid boy (and place it onto an additional plane, which is passive then), the rotation will be integrated into the physics simulation.
but this unfortunatley has the side effect, that the dynamics of the system is compelelty differnt. To fix this, might be more complicated than to understand the structural way blender python interacts with the physics environment.
- edit: I found some interesting information here: https://www.youtube.com/watch?v=YpUyGJ-do4o
So following the ideas in the video one approximation to the combination between external control and integration into physics calculation could be to set the rigid body settings to "animated" in e.g. each odd frame, and then to "dynamic" in each even frame. This allows a possibilty to set positions and rotations via a python script and let the changed values be incorporated into the physics calculations.
Anyway: even better would be a bpy way to set positions directly into the physics world in arbitrary frames, to get a fluid frame by frame simulation with external control of some objects.