Added automatically set velocity when rigid is kinematic

This commit is contained in:
Andrea Catania 2018-09-19 19:46:07 +02:00
parent 42f2ff2f8d
commit 0a2c154c8e
1 changed files with 4 additions and 1 deletions

View File

@ -351,7 +351,7 @@ void RigidBodyBullet::set_space(SpaceBullet *p_space) {
void RigidBodyBullet::dispatch_callbacks() {
/// The check isTransformChanged is necessary in order to call integrated forces only when the first transform is sent
if ((btBody->isActive() || previousActiveState != btBody->isActive()) && force_integration_callback && isTransformChanged) {
if ((btBody->isKinematicObject() || btBody->isActive() || previousActiveState != btBody->isActive()) && force_integration_callback && isTransformChanged) {
if (omit_forces_integration)
btBody->clearForces();
@ -774,10 +774,13 @@ Vector3 RigidBodyBullet::get_angular_velocity() const {
void RigidBodyBullet::set_transform__bullet(const btTransform &p_global_transform) {
if (mode == PhysicsServer::BODY_MODE_KINEMATIC) {
if (space)
btBody->setLinearVelocity((p_global_transform.getOrigin() - btBody->getWorldTransform().getOrigin()) / space->get_delta_time());
// The kinematic use MotionState class
godotMotionState->moveBody(p_global_transform);
}
btBody->setWorldTransform(p_global_transform);
scratch();
}
const btTransform &RigidBodyBullet::get_transform__bullet() const {