1. Entity A go to point B, thus the direction vector is vector AB.
2. Convert direction (vector AB) to angle to rotate rigid body of Entity A.
3. Rotate rigid body of Entity A.
And here is how I rotate rigid body
Code: Select all
btRigidBody* body;
btQuaternion rot;
btTransform trans = body->getWorldTransform();
rot = trans.getRotation();
btScalar curAng = rot.getAngle();
rot.setRotation(btVector3(0, 1, 0), curAng + 90);
trans.setRotation(rot);
// apply new rotation
body->setWorldTransform(trans);
1. How can I convert direction (vector AB) to angle to rotate rigid body of Entity A?
2. Is there a way I can directly set the direction of physic entity A?