New rigid-body position doesn't get effected by gravity

Lil_Margin
Posts: 10
Joined: Sun Jul 19, 2009 5:24 am

New rigid-body position doesn't get effected by gravity

Post by Lil_Margin »

Hey,
I am new to the Bullet Physics Engine but after following the "Bullet Hello World Tutorial" i got some basic understanding of how Bullet works.
I have a ball/sphere rigid-body that falls to a plane nicely with gravity but when i reposition the sphere rigid-body the rigid-body doesn't get effected by the world gravity.
I am using this code in my keyboard key to reposition the sphere rigid-body

Code: Select all

            btVector3 oldorigin = trans.getOrigin();
            trans.setOrigin(btVector3(0,50,0));
            fallRigidBody->getMotionState()->setWorldTransform(trans);
            fallRigidBody->setCenterOfMassTransform(trans);

when the program begins the sphere rigid-body position goes from 50 to 0 (cause of gravity) but when i reposition the rigid-body it stays at 50 :?
Am i missing something in my code or am i doing the reposition completely wrong?
Thanks in advanced.
Lil_Margin
Posts: 10
Joined: Sun Jul 19, 2009 5:24 am

Re: New rigid-body position doesn't get effected by gravity

Post by Lil_Margin »

I notice that it works until my sphere hits the plane, when it hits the plane it seems like gravity doesnt effect my sphere rigidbody anymore.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: New rigid-body position doesn't get effected by gravity

Post by Erwin Coumans »

You might have to activate the rigid body:

Code: Select all

body->activate();
Hope this helps,
Erwin
Lil_Margin
Posts: 10
Joined: Sun Jul 19, 2009 5:24 am

Re: New rigid-body position doesn't get effected by gravity

Post by Lil_Margin »

Thanks it works, so i guess when a dynamic rigid-body collides with a static object it deactivates, or am i wrong?