# Different frames make rigid bodies act differently

So I am writing a small script to set initial speeds for objects in the Rigid Body system. It is really bare bones right now, but it essentially sets a keyframe for the selected object on the frame number of a variable called start_frame.

The goal of the script is so I can choose a start frame and a speed, and the object will have all of the correct keyframes set so it can just launch off with an initial speed. The problem is that depending on what frame I set start_frame to be, the cube reacts differently.

Here is what I mean:

If start_frame equals 1, the object is launched and then falls off the plane.

If start_frame equals any number greater than 1, the object doesn't travel as far.

From what I understand, there shouldn't be any difference because the distance between the start and end keyframes is always the same.

I looked at the graph editor but the only change I am seeing between the two conditions is being shifted, just like it should be.

I am so confused why changing the frame from 1 to anything above 1 would give such a different result.

So is there anything special about frame 1? And if so, how can I avoid this problem in my script?

• that's because end_frame = start_frame + speed so "end frame" is always "speed" frames away from the "star_frame" – Chebhou Apr 23 '15 at 23:08
• @Chebhou That is exactly what is supposed to happen. The start_frame defines the frame to start the animation on. I just want the cube that is launched to have the same physics no matter what frame it is launched on. I will upload a GIF to explain what I mean. – Nathan Craddock Apr 24 '15 at 3:59
• if you travel the same distance in the same duration you will end up in the same place no matter what late you are, duration needs to change but in your script it's constant as the distance is , why do you expect the result to be different ? – Chebhou Apr 24 '15 at 10:17
• @Chebhou The result is different, and that is what is bugging me. I will reword my question and hopefully it will make more sense. For now, take a look at the GIFs I uploaded. The first one start_frame set to 1, and the second shows it set to frame 2. The result is different and I am very confused. – Nathan Craddock Apr 24 '15 at 22:03
• here is what is even weird : if the start_frame is odd it will fall off the plane , but if it is even it will stop before, even at larger numbers – Chebhou Apr 24 '15 at 22:22

The problem is the animation starts at frame_start and ends at frame_end and since end_frame = start_frame + speed the duration is always the same but shifted.
To achieve the desired effect the animation duration should get longer when frame_start gets larger, one way to do it is to set the first keyframe at 0.
so the first key frame shouldn't be the start_frame :

    # First keyframe
scene.frame_current = 0
bpy.ops.anim.keyframe_insert(type='Location')
print(start_location)


if you want to start at frame_start and end at frame_end and get different results you have to change the frame_end expression :

frame_end = speed + 2*frame_start


this way the delay the start the longer the duration is , giving the cube lower speed ( less momentum ) and it will travel shorter

So in order to fix this problem, the steps per second need to be a multiple of the current frames per second. Not exactly sure why this is, but it will make everything more stable!