0

So I've been able to use bullet physics to bind a rigid body to a cube and have it fall while being rendering, but when I tried to "attach" a rigid body to the player it got the player stuck underneath the world, unable to move.

I was originally going use kinematic bodies but after research and trying them seems like their incomplete.

My question in the end would be am I handling the data correctly to update my camera's position and also changing the rigid bodies.

-Below is the code I use create the rigid body, and below that is the code to update both of their positions.

btTransform t;
t.setIdentity();
t.setOrigin(btVector3(0, 0, 0));
btCapsuleShape* player = new btCapsuleShape(1, 1);
btVector3 inertia(1, 0, 0);

player->calculateLocalInertia(20, inertia);

btMotionState* motion = new btDefaultMotionState(t);
btRigidBody::btRigidBodyConstructionInfo info(20, motion, player, inertia);
PlayerBody = new btRigidBody(info);
world->addRigidBody(PlayerBody);
bodies.push_back(PlayerBody);
PlayerBody->setAngularVelocity(btVector3(0,0,0));

And the code to update the position of therigid body and camera

gCamera.GetInput(window);

btVector3 t;

t = physics.PlayerBody->getLinearVelocity();

gCamera.position.x = t.getX();
gCamera.position.y = t.getY();
gCamera.position.z = t.getZ();

//Set
physics.PlayerBody->setLinearVelocity(btVector3(gCamera.position.x, gCamera.position.y, gCamera.position.z));
Arko
  • 65
  • 2
  • 11
  • Shouldn't you set the camera position to the position of the player? It would seem to me like you are setting it to player velocity and then you set the player velocity to the position of the camera? That doesn't make sense. – user2802841 Mar 02 '14 at 20:57
  • Changing it to the rigid body's motionstate has some weird effect which makes the camera see black, but I think this is because it makes the camera face down. – Arko Mar 03 '14 at 01:43
  • @user2802841 forgot to above – Arko Mar 04 '14 at 00:43

0 Answers0