I've just started implementing bullet into my Ogre project. I followed the install instructions here: http://www.ogre3d.org/tikiwiki/OgreBullet+Tutorial+1

And the rest if the tutorial here: http://www.ogre3d.org/tikiwiki/OgreBullet+Tutorial+2

I got that to work fine however now I wanted to extend it to a handle a first person camera. I created a CapsuleShape and a Rigid Body (like the tutorial did for the boxes) however when I run the game the capsule falls over and rolls around on the floor, causing the camera swing wildly around.

I need a way to fix the capsule to always stay upright, but I have no idea how

Below is the code I'm using.

(part of) Header File

OgreBulletDynamics::DynamicsWorld *mWorld;   // OgreBullet World
OgreBulletCollisions::DebugDrawer *debugDrawer;
std::deque<OgreBulletDynamics::RigidBody *>         mBodies;
std::deque<OgreBulletCollisions::CollisionShape *>  mShapes;

OgreBulletCollisions::CollisionShape *character;
OgreBulletDynamics::RigidBody *characterBody;
Ogre::SceneNode *charNode;

Ogre::Camera* mCamera;
Ogre::SceneManager* mSceneMgr;
Ogre::RenderWindow* mWindow;

main file

bool MinimalOgre::go(void)

     mCamera = mSceneMgr->createCamera("PlayerCam");
     mCameraMan = new OgreBites::SdkCameraMan(mCamera);

    OgreBulletCollisions::CollisionShape *Shape;
    Shape = new OgreBulletCollisions::StaticPlaneCollisionShape(Vector3(0,1,0), 0); // (normal vector, distance)
    OgreBulletDynamics::RigidBody *defaultPlaneBody = new OgreBulletDynamics::RigidBody(
    defaultPlaneBody->setStaticShape(Shape, 0.1, 0.8); // (shape, restitution, friction)
    // push the created objects to the deques

    character = new OgreBulletCollisions::CapsuleCollisionShape(1.0f, 1.0f, Vector3(0, 1, 0));

    charNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();

    characterBody = new OgreBulletDynamics::RigidBody("character", mWorld);
    characterBody->setShape(   charNode,
                    0.0f,         // dynamic body restitution
                    10.0f,         // dynamic body friction
                    10.0f,          // dynamic bodymass
                    Quaternion(0, 0, 1, 0));


  • 1
    \$\begingroup\$ In bullet you can use rigidBody->setAngularFactor(btVector3(0,0,0)) to constrain rotations. Perhaps an Ogre equivalent can be used. \$\endgroup\$
    – 5ound
    Jan 16, 2012 at 8:04

3 Answers 3


I actually just finished writing this for my capsule object yesterday.

You just need to call btRigidBody::setAngularFactor(btVector3(Yaw, Pitch, Roll)); Calling it with all 0s will prevent your object from rotating on any angle.

Here is where I originally found the answer: http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?p=&f=9&t=2956

(In reply to that thread I have had no issues using Bullet 2.79 and setAngularFactor)


I've never used Bullet, but in Havok you could constrain a model on certain axes. If you can constrain rotation of your model on both horizontal axes that may stop it from falling over. Alternatively Havok let you have a special type of physics called a CharacterProxy, each from you could for it to face straight up, and you could also run your own code for its physics simulation so you could prevent rolling. This is similar to how the JigLib/JigLibX physics engines handle it as well. I'm willing to bet Bullet allows one of these methods.


A capsule shape will fall and roll around according to its physical properties. If you want to couple your camera to a physics object, why not use btBoxShape (or the Ogre equivalent) instead?

I don’t really know what you’re trying to do, but my suggestion would be to have the camera separate from the physics. That way, you’ll be able to move it as you like.

  • \$\begingroup\$ And if he wants to do a fps? Well, camera -> mesh -> physics, keep this inheritance and i think that should do. \$\endgroup\$ Jan 16, 2012 at 7:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .