How can I set the linearVelocity so that the object travels a specific distance with python?

What velocity should I set an object to in order to have it travel 30 Blender Units in 0.25 seconds.The object will be traveling on its Y local axis. This is being done in python rather than an actuator because I couldn't get the results I needed, and I imagine that there is a specific syntax for velocity. This object is being spawned on a click. Then, when its timer property is 0.25 or more, it dies. I need it to travel that exact (or pretty close...no one would notice that much) distance before then.

• I'm not sure, but I believe you could just use velocity=distance/time, in your case velocity=30/0.25 or 120 BU/s. Not this only works if your object is travelling at a constant speed, and you need to make sure you're using the correct units BU/s, not BU/frame (the conversion factor is your fps) or something else Commented Jan 18, 2014 at 22:15
• So if I want it to travel 120BU/s on the local Y-axis, what would the syntax look like? Commented Jan 20, 2014 at 15:04

1 Answer

Use velocity=distance/time, in your case velocity=30/0.25=120 BU/s however the blender game engine units are BU/game-frame (default=60) therefore the correct value would be 2 BU/game-frame. To make the object travel 120BU/s on the local Y-axis, I believe you need to use (assuming default game-frame):

setLinearVelocity((0.0,120.0,0.0),True)

EDIT: Apparently the units are BU/s