Using angular velocity to orient a rigid body

I have a rigid body which I want to move towards and match its rotation with another object in the scene, but still be affected by collisions from other rigid bodies. I have figured out how to do the movement part:

cont = bge.logic.getCurrentController()
own = cont.owner
target = bge.logic.getCurrentScene().objects['Cube']

own.worldLinearVelocity = target.worldPosition-own.worldPosition

But I can’t figure out how to apply this to do the same with orientation, because the worldAngularVelocity method accepts a rotation vector instead of a matrix or quaternion. So is there any way to “convert” a matrix or quaternion into this 3-vector?

May be you could try:


from mathutils import Vector
own.worldAngularVelocity = K*(Vector(target.worldOrientation.to_euler()) - Vector(own.worldOrientation.to_euler()))

where K is a positive scalar constant used for scaling purposes.

you could use:


turnSpeed = 0.1
own.worldOrientation = own.worldOrientation.lerp(target.worldOrientation, turnSpeed)

The result being a smooth rotation that ends with both objects haveing the same orientation.

This one works best for my situation, thanks