# need own.getAngularVelocity? but is none?

Hi,
I want to know the angular velocity of an object in python. Does anyone know how to do this?
i want to make a rotational dampener proportional to the rotating speed because there is no python code for setting the RotDamp… which would change depending on what surface a car would be on.
thanks for the help
-ineedanewbike

Great question,
Nope. There is absolutely no command that can do anything to the velocity of an object, though I do think a thread have been started on it somewhere in the Blender dev forum…

you might try comparing the orientation between one frame and the next- there’s more thinking involved than I want to do now, though.

you can use the apply impulse function… check the API i’m not to sure how to use it… but someone used it to remove the velocity from objects… http://www.blender.org/documentation/pydoc_gameengine/PyDoc-Gameengine-2.34/indices.html ack the message post editor won’t ket me add the link or click any of the buttons strange…so I can’t make a proper link oh well?

Yes, the impulse function basically adds linear velocity to the object … to quote from my slides&slopes project:

``````
# Removes the velocity of an object.
def remove_velocity(obj):
if obj != None:
# Get the current velocity of the object.
vel = obj.getVelocity()

print "Removed velocity of object: " + obj.name
# Cancel out current velocity with negative values.
obj.applyImpulse([0,0,0], [-vel[0],-vel[1],-vel[2]])

``````

But as far as I know there isn’t a way to change the angular velocity with it (or aith another function), is there? :-/

EDIT: Nice

Werner

1 Like

hi hoehrer what does the “obj” refer too? is this a variable you’ve defined earlier, def remove_velocity(obj): if obj != None: not sure of these two lines… the first one gives/defines the script a name… but why the (obj)? and what does the following do exactly? if obj != None:

Woah. I was totally unaware of this command index, and the command. This really helps, thanks Kirado!

hmm, i’m not sure how reliable the angular velocity would be if i compared the orientaion at different times… i’m open to any helpful code suggestions, but i could use a timer/increasing number, and have 2 properties, durring an odd time it could record orentation to property 1 and even time record to property 2… then have another script subtract the two and divide by the time interval… i’m only afraid that the timers wont be consistant, and there may be a large difference depending on the framerate… but i guess its the best solution i have right now.

i’ve never used apply impulse before which might be useful if i want to instantaneously stop objects completely… i always thought it was a force. when my car runs from concrete to grass, i can take in the cars velocity and if its on grass, i can add a frictional force (negative force constant*velocity)… so the car moves slower on other surfaces… its too bad theres only a own.getVelocity() and no own.getAngularVelocity()
thanks for the help so far.

Very useful information! This thread deserves a bump. = )

I don’t want to code this right now, but it seems like it would work if you saved the orientation into object variables (which are persistent from frame to frame), then next frame compared it to the new orientation (the orientation in the variables will be from the previous frame). if the turning is more than whatever you want it to, apply torque in the opposite direction according to that. you should only need to save one axis, as you’re just gonna be dealing with horizontal damping.