Proper use of Bullet in a First Person Shooter game

josemarin
Posts: 38
Joined: Fri Aug 12, 2005 5:37 pm

Proper use of Bullet in a First Person Shooter game

Post by josemarin »

Hi.

I´m integrating Bullet in a FPS game, and would like to know your 'recipes' to do that.

I´m thinking on using a capsule for the player.

The capsule is allways upwards.

My problem is how to animate the capsule, for example, when the player is walking.
Should I apply force or impulse?
What kind of object would be better?

Thanks !

Jose
Wavesonics
Posts: 71
Joined: Thu May 22, 2008 8:03 pm

Re: Proper use of Bullet in a First Person Shooter game

Post by Wavesonics »

Using a capsule for the player is probably best, but making the capsule dynamic will complicate things just a tad.

See if it is dynamic and you have gravity, I'm pretty sure it will just fall over.

The best way I can think to solve this would be to create a constraint. Much like the solution for restricting things to 2D motion. Create a "zero body", just a body that sits at (0,0,0) with no rotation and is not collidable or dynamic.

Then you attach your player capsule to it with a constraint. The key here is to have the constraint not lock any of the translation freedoms and only 2 of the rotation freedoms. So say, yaw is free, but pitch and roll are locked. And you could maybe have pitch locked to a certain range so they can look up and down but not fall over? I'm not sure. I think again gravity would frustrate this effort.

So onto the another possible solution! Make the capsule not dynamic. So you can set the capsules location and rotation manually to move it and have no chance of falling over.

This is easy, but provides other problems. Namely, you need to do the movement calculations your self, and you need to do special cased for things in the physical world moving your player (like an explosion couldn't apply an impulse, your own code would instead have to maintain velocities and calculate the new position)

The last possibility would be to constantly reset the rotations to what you want, and maybe Bullets devs can weigh in here, but to my knowledge this is a bit dangerous and can lead to simulation instability.

Sorry if this wasn't terribly helpful, i guess i just provided more questions then answers, I'm rather new to bullet as well and am not using it in this capacity.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Proper use of Bullet in a First Person Shooter game

Post by Erwin Coumans »

We are working on an example character controller, and try to provide a prototype in Bullet 2.70.

Thanks,
Erwin
Wavesonics
Posts: 71
Joined: Thu May 22, 2008 8:03 pm

Re: Proper use of Bullet in a First Person Shooter game

Post by Wavesonics »

Oh Erwin, is there nothing you can't do *so dreamy*
Mr.Newb
Posts: 9
Joined: Sat Nov 10, 2007 7:28 am

Re: Proper use of Bullet in a First Person Shooter game

Post by Mr.Newb »

Wavesonics wrote:Oh Erwin, is there nothing you can't do *so dreamy*
Yea...If he wrote a game physics book I would read it over and over again. [Kick Eberly to the curb]
FailMaT_T
Posts: 10
Joined: Thu Jul 03, 2008 4:51 pm

Re: Proper use of Bullet in a First Person Shooter game

Post by FailMaT_T »

Is it possible to prevent the capsule from falling over by overriding the gravity setting for the btRigidBody. I assume thats what the method setGravity() in btRigidBody does? Although of course this poses the problem of the capsule never falling down holes etc