Page 1 of 1

my bodies don't move when applying force to them... :\

Posted: Tue Aug 21, 2012 11:18 am
by khoowaikeong
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. :oops:

Re: my bodies don't move when applying force to them... :\

Posted: Tue Aug 21, 2012 4:58 pm
by zarlox
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.

Re: my bodies don't move when applying force to them... :\

Posted: Wed Aug 22, 2012 2:56 am
by khoowaikeong
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);
}

Re: my bodies don't move when applying force to them... :\

Posted: Wed Aug 22, 2012 4:54 am
by khoowaikeong
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... :oops: