chandlerprall / GoblinPhysics

Collision Detection & Response in JavaScript
http://www.goblinphysics.com
Other
147 stars 18 forks source link

Damping rotations?? #42

Closed Druidhawk closed 9 years ago

Druidhawk commented 9 years ago

In the various demos when shapes collide they spin in three dimensions forever, I would like to dampen this such that the rotation forces diminish toward zero. I wonder if there is something similar to surface friction to drive this or do I need to handle myself. Basically if I throw a rock at a bird, it spins during the collision, but eventually the bird would right itself.

chandlerprall commented 9 years ago

Rigid bodies have both a angular_damping and linear_damping property which is a Float amount of velocity the object will lose every second. This will not automatically orient your bird the correct way, but you could set damping to slow the rotation and also perform some small amount of rotation/quaternion correction manually each frame to get the bird back how you want it.