29
$\begingroup$

I'm trying to create a bowling animation and I want the ball to hit the pins. I already added the Rigid Body physics to the objects but can't get the ball to move.

Obviously I could just add keyframes but

  • that seems to interfere with the Rigid Body physics
  • it doesn't look too realistic.

Is there a way to add some kind of motion to the ball?

$\endgroup$

4 Answers 4

40
$\begingroup$

Using keyframes is the only way I know of to do this currently, but you should be able to get good results by allowing the rigidbody object to be controlled by the animating system, then switching control back to the physics system while maintaining momentum gained from the keyframe animation.

This can be done by animating the Animated option in Physics > Rigid Body.
See the wiki:

The most common trick is to keyframe animate the location or rotation of an Active physics object as well as the Animated checkbox. When the curve on the Animated property switches to disabled, the physics engine takes over using the object's last known location, rotation and velocities.

Also see this post

For example:

  1. Enable Animated on your rigidbody object and insert a keyframe by right clicking on the check box and selecting Insert Keyframe:

    enter image description here

  2. On the same frame, add a location keyframe (or rotation if you want some angular momentum) to the rigid body object

  3. Go to a later frame and insert another location keyframe

  4. On the same frame, disable Animated and insert a keyframe by right clicking on the Animated checkbox and selecting Insert Keyframe again.

The motion from the keyframed animation will be carried over to the motion of the object as it is controlled by the physics system.

Result:

enter image description here

Note that while Animated is enabled the object will still interact with other rigid bodies, however its motion will be controlled by the animation system.

$\endgroup$
10
  • 1
    $\begingroup$ Is there any way to simply set the object's velocity at the first frame? $\endgroup$ Commented Jan 26, 2015 at 7:52
  • $\begingroup$ @snapfractalpop Not currently. $\endgroup$
    – gandalf3
    Commented Jan 26, 2015 at 7:54
  • 2
    $\begingroup$ Ok. I just tried your method, and I found that I needed to have at least two frames with "animated" checked. I guess that is needed to calculate momentum. $\endgroup$ Commented Jan 26, 2015 at 8:33
  • 1
    $\begingroup$ @snapfractalpop Yes, exactly. The object needs to be moving when the rigid body simulator takes over. $\endgroup$
    – gandalf3
    Commented Jan 26, 2015 at 8:37
  • $\begingroup$ It doesn't appear to be working. Can you give a .blend download so I can analyze what you did for that bowling ball example. $\endgroup$ Commented Mar 26, 2015 at 18:42
10
$\begingroup$

I have created an addon to make this process described by gandalf3 easier. It's called Projectile. Download it from GitHub. The download is for 2.8x, for a 2.7x version see this branch

To use it

  1. Select an object
  2. In the sidebar (N panel) there is a panel called Projectile. In the panel is a button titled "Add Object." Click to initialize velocity.
  3. In the Velocity Settings subpanel, set the velocity. By default, the operator will run each time a setting is changed.
  4. Then play the animation! You will see the object start with an initial velocity.
  5. There are many other settings like initial location and rotation, start frame, angular velocity, physics solver quality, auto updating, auto play, trajectory drawing. Experiment with the settings to get a good result.

For more detailed instructions see the readme on GitHub.

$\endgroup$
1
  • $\begingroup$ This is fantastic! Works as advertised. $\endgroup$ Commented Jan 25, 2018 at 21:51
0
$\begingroup$

I wondered a similar thing (Using "Rigid Body" for rolling ball. Flat surface. How to push the ball to roll?) and someone in the comment mentioned this question. The top answer worked, but only when I had sufficient length of moving animation right before the physics (moving between frame 1 and 2 did not work, I had to make it between frame 1 and 20). But that defeats the purpose of this physics movement. I was thinking about adding this physics movement because I wanted to avoid the unrealistic sliding animation, and now I have to add it to make the physics work.

So, I modified the top answer slightly. Instead of animating the ball itself, I added an invisible cube and animated that cube. Basically the cube hits the ball, and the ball starts to rolling. I extrude the top part of the cube a little bit so it would hit the top part of the ball. I am not sure if it affects the animation or not.

enter image description here

You don't need to add any special keyframes to the ball itself. Do

  1. Add a cube to some tens of frames before, set keyframes on its location.
  2. Make the cube a "Rigid Body"
  3. At the frame you want the ball to start rolling, move the cube to a location where it slightly touches the ball and set keyframes on the cube's location.
  4. Make the cube invisible in the render result (Outliner -> filter -> camera icon -> uncheck for the cube) enter image description here
$\endgroup$
0
$\begingroup$

I would like to post a python script implementation of @gandalf3's idea.

I am new to blender, I have read What is the correct python code for pressing "I" and selecting LocRotScale? and How to use Keyframes and the Python API programmatically?. Referring to how to find the data_path for scripted keyframes, I finally get the following:

bpy.context.scene.frame_set(5)
cube.rigid_body.kinematic = True
cube.keyframe_insert(data_path="rigid_body.kinematic")
cube.keyframe_insert(data_path="location")
cube.keyframe_insert(data_path="rotation_euler")
bpy.context.scene.frame_set(10)
cube.keyframe_insert(data_path="location")
cube.keyframe_insert(data_path="rotation_euler")
cube.rigid_body.kinematic = False
cube.keyframe_insert(data_path="rigid_body.kinematic")

In this way, one can first control the rigid body motion manually, and then transfer the control to the physics system.

I also find the following links may be useful: Simulations Rigid Bodies and The manual.

$\endgroup$
1
  • $\begingroup$ hellohawaii, your answer looks promising. Would you please post the entire script and give a complete but simple example of how to successfully use it? Even after adding "import bpy" at the top of script, I get "name 'cube' is not defined". $\endgroup$ Commented Mar 10 at 20:22

You must log in to answer this question.

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