Gravity to 0 ?

Hurricanes
Posts: 6
Joined: Wed Jun 16, 2010 8:40 am

Gravity to 0 ?

Post by Hurricanes »

Heya,

I've got a simple application with a single btRigidBody to which I apply forces by pressing keys. If I set the world gravity to something else than 0, it works fine, but if i set the gravity to ( 0,0,0 ) during the physics initialization then my object doesnt move when I apply forces.

I just do the following :

Code: Select all

m_PhysicsWorld = new btDiscreteDynamicsWorld( m_Dispatcher,m_Broadphase,m_Solver,m_CollisionConfig );
m_PhysicsWorld->setGravity( btVector3( 0,-10,0 ) );
And then, to apply a force :

Code: Select all

if ( m_Cube )
{
	m_Cube->applyForce( btVector3( 0,100,0 ), btVector3( 0,0,0 ) );
}
The applyForce() call does nothing if the gravity has been set to 0,0,0 during the init. Any idea what's going on ? It's probably me doing something wrong but I can't see what :)

thanks in advance,

Hurricanes.
Hurricanes
Posts: 6
Joined: Wed Jun 16, 2010 8:40 am

Re: Gravity to 0 ?

Post by Hurricanes »

Any ideas ?

Thanks,


Hurricanes.
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Gravity to 0 ?

Post by dphil »

What's the linear dampening of your object set to? I think I've had it before where I've set the dampening to 1 and small applied forces don't have any (or unnoticeable) effect. If that's the case try setting the dampening to 0 and increasing the force applied. Otherwise I'm not sure what the problem might be.
Hurricanes
Posts: 6
Joined: Wed Jun 16, 2010 8:40 am

Re: Gravity to 0 ?

Post by Hurricanes »

I haven't touched the linear damping, so I guess it's set at its default value. I set it to 0 but it didn't change the problem, it seems something else is wrong. Still not sure what :)

Thanks for your answer,

Hurricanes.
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: Gravity to 0 ?

Post by sparkprime »

activate the object when you apply the force

objects that are stationary for a period (see linear sleep threshold and friends) will deactivate and will not be processed until they are collided or explicitly reactivated