they react to gravity and each other but setting:
pRigidBody->setLinearVelocity(btVector3(_force.x, _force.y, _force.z));
,
pRigidBody->applyCentralImpulse(btVector3(_force.x, _force.y, _force.z));
or
pRigidBody->applyCentralForce(btVector3(_force.x, _force.y, _force.z));
does completely nothing.
my bodies don't move when applying force to them... :\
-
- Posts: 43
- Joined: Fri Jun 15, 2012 7:11 am
-
- Posts: 31
- Joined: Tue Apr 26, 2011 5:52 pm
Re: my bodies don't move when applying force to them... :\
Can you post your code that create the body and add it to the world?
Usually, when the body do not move,either the body was not added properly to the world or the body deactivation state is not right.
Usually, when the body do not move,either the body was not added properly to the world or the body deactivation state is not right.
-
- Posts: 43
- Joined: Fri Jun 15, 2012 7:11 am
Re: my bodies don't move when applying force to them... :\
it react to collision so i don't think it not added correctly,
void ColliderUnit::addToScene(ColliderScene* _pColliderScene)
{
removeFromScene();
if(!_pColliderScene) return;
pColliderScene = _pColliderScene;
//---------------------------------------------------
pRigidBody = new ColliderRigidBody(mass, this, pCollisionShape, btVector3(0,0,0));
// some default setting
pRigidBody->setFriction(1);
//---------------------------------------------------
btDynamicsWorld* pDynamicsWorld = pColliderScene->getDynamicsWorld();
pColliderScene->addColliderRigidBody(pRigidBody, type);
//pDynamicsWorld->addCollisionObject(pRigidBody, type, ColliderUnitTypeMasking(type));
//pDynamicsWorld->addRigidBody(pRigidBody);
//removed cached contact points (this is not necessary if all objects have been removed from the dynamics world)
if (pDynamicsWorld->getBroadphase()->getOverlappingPairCache())
pDynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(pRigidBody->getBroadphaseHandle(),pDynamicsWorld->getDispatcher());
wake();
//gColliderUnitCounter++;
//cout<<"gColliderUnitCounter:"<<gColliderUnitCounter<<endl;
}
void ColliderUnit::wake()
{
if(!pRigidBody)return;
cout<<"ColliderUnit::wake() ";
pRigidBody->forceActivationState(ACTIVE_TAG);
pRigidBody->activate();
pRigidBody->setDeactivationTime(0);
}
void ColliderUnit::addToScene(ColliderScene* _pColliderScene)
{
removeFromScene();
if(!_pColliderScene) return;
pColliderScene = _pColliderScene;
//---------------------------------------------------
pRigidBody = new ColliderRigidBody(mass, this, pCollisionShape, btVector3(0,0,0));
// some default setting
pRigidBody->setFriction(1);
//---------------------------------------------------
btDynamicsWorld* pDynamicsWorld = pColliderScene->getDynamicsWorld();
pColliderScene->addColliderRigidBody(pRigidBody, type);
//pDynamicsWorld->addCollisionObject(pRigidBody, type, ColliderUnitTypeMasking(type));
//pDynamicsWorld->addRigidBody(pRigidBody);
//removed cached contact points (this is not necessary if all objects have been removed from the dynamics world)
if (pDynamicsWorld->getBroadphase()->getOverlappingPairCache())
pDynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(pRigidBody->getBroadphaseHandle(),pDynamicsWorld->getDispatcher());
wake();
//gColliderUnitCounter++;
//cout<<"gColliderUnitCounter:"<<gColliderUnitCounter<<endl;
}
void ColliderUnit::wake()
{
if(!pRigidBody)return;
cout<<"ColliderUnit::wake() ";
pRigidBody->forceActivationState(ACTIVE_TAG);
pRigidBody->activate();
pRigidBody->setDeactivationTime(0);
}
-
- Posts: 43
- Joined: Fri Jun 15, 2012 7:11 am
Re: my bodies don't move when applying force to them... :\
ignore that, it was the scale too small. apparently i need to apply a force of 100000 to see anything due to the unit scale we have...