• Advertisement
Sign in to follow this  

Sphere acting like a ball in Bullet Physics

This topic is 1893 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a sphere and trying to make it act like a ball, so when it move, it should rotate as well like physical ball, and when it hit something, it should bounce, here is the code I am using:[CODE]
/// Create Dynamic Objects
btTransform startTransform;
btScalar mass(0.1f);
//rigidbody is dynamic if and only if mass is non zero, otherwise static
bool isDynamic = (mass != 0.f);
btVector3 localInertia(0,0,0);
if (isDynamic)

//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,colShape,localInertia);
btRigidBody* body = new btRigidBody(rbInfo);

When I use the above code, the sphere does not rotate when moving (it's moving just like a normal box) neither it bounce when it hit the floor from gravity).

How can I get it to bounce and rotate while moving?

Share this post

Link to post
Share on other sites
It will only roll if it has friction.

Similarly it will only bounce if it has a non-zero restitution.

You can set these things in rbInfo. You'll also need to set them on the environment objects as well, because the resulting behaviour is determined by the combination of restitution & friction. Probably Bullet calculates them by multiplying the properties of the two interaction objects - so for starters, make restitution and friction = 1 on everything, and then modify it until you get the behaviour you want.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement