• Advertisement
Sign in to follow this  

Bullet physics character

This topic is 1320 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 tried a lot searching on google about bullet physics character tutorial but I found nothing. So, I'm posting here. I want my character using bullet physics. I mean it should be able to walk left, right, forward and backward. I also want it to move in the direction where camera is looking. E.g Camera is looking back but pressing 'W' would take him in his back because camera is looking back. I don't want this. I want to walk forward in the direction of camera and i also want the Character to do collision detection with the objects in the world. How is this achieved using bullet physics? So far I found m_RigidBody->SetLinearVelocity(x, y, z); but it does not take camera's direction into consideration. m_RigidBody->ApplyCentralForce also doesn't work well for me. Also the Character's movement is unrealistic using SetLinearVelocity. What should I do? do you have have tutorial on setting up character in bullet?

Edited by newtechnology

Share this post


Link to post
Share on other sites
Advertisement

Take camera forward direction  vector and setLinearVelocity with it.

Share this post


Link to post
Share on other sites

Using a rigid body as a character controller is fraught with issues. You should take a look at btKinematicCharacterController. Not sure what state it is in these days, had a few issues last time I looked.

Share this post


Link to post
Share on other sites

Using a rigid body as a character controller is fraught with issues. You should take a look at btKinematicCharacterController. Not sure what state it is in these days, had a few issues last time I looked.

It's undocumented, and quite messy. And considering Bullet itself is poorly documented you won't find explanations for most of the things you won't know in it.
I personally implemented my own character controller for that reason. It takes some work but probably less than "reverse engineer" btKinematicCharacterController, and you'll understand everything in it.

Share this post


Link to post
Share on other sites

I made controller based on btKinematicCharacterController and another based on rigid body for testing puposes

Both need work. Much more on btKinematicController I think.Its ghost object so you must calculate collisions yourself.

At the end I went rigid body way.

Clip:

Edited by MARIO_H

Share this post


Link to post
Share on other sites

From what I understand ghost objects are for detecting collision between specific objects, so it's suitable for pickups for example.

Share this post


Link to post
Share on other sites

I made controller based on btKinematicCharacterController and another based on rigid body for testing puposes

Both need work. Much more on btKinematicController I think.Its ghost object so you must calculate collisions yourself.

At the end I went rigid body way.

Clip:

 

Looks good. Did you try to implement sloping floors though? That was the thing I could never get right with a Bullet rigid body. Messing about with friction and trying to stop it sliding down the slopes drove me to distraction.

Share this post


Link to post
Share on other sites

From what I understand ghost objects are for detecting collision between specific objects, so it's suitable for pickups for example.

 

In this context, ghost object is just a Bullet shape that is created without being part of the simulation, for the purposes of querying collisions with the environment. The btKinematicCharacterController uses a ghost shape to check for collisions in the requested target position and correct the position.

 

I agree it is a mess and not usable last time I looked. But having just spent a long time implementing my own character controller I'd point out this is absolutely non-trivial and very hard to get something as stable as, say, Havok's.

Share this post


Link to post
Share on other sites

 

I made controller based on btKinematicCharacterController and another based on rigid body for testing puposes

Both need work. Much more on btKinematicController I think.Its ghost object so you must calculate collisions yourself.

At the end I went rigid body way.

Clip:

 

Looks good. Did you try to implement sloping floors though? That was the thing I could never get right with a Bullet rigid body. Messing about with friction and trying to stop it sliding down the slopes drove me to distraction.

 

Yes. On slopes larger than about 45 degrees I get very slow sliding down.I will have to look into it.

Share this post


Link to post
Share on other sites


Yes. On slopes larger than about 45 degrees I get very slow sliding down.I will have to look into it.

 

Best of luck. I found this unsolvable. Its a shame as on flat surfaces, you can get away with using a rigid body as a character controller fairly well, but the slope sliding is a deal breaker for me.

Share this post


Link to post
Share on other sites
So i tried kinematic character controller from bullet physics and i don't have a problem yet. I used the code from characterdemo of bullet physics and managed to walk in the direction where player is looking, but there is no code in the demo for moving left or right. How can i achieve this?

Share this post


Link to post
Share on other sites

So i tried kinematic character controller from bullet physics and i don't have a problem yet. I used the code from characterdemo of bullet physics and managed to walk in the direction where player is looking, but there is no code in the demo for moving left or right. How can i achieve this?

 

You have an up vector and you have the forward vector. Do a cross product on these to get the right vector. Then just move the controller by multiples of this vector, either adding or subtracting.

 

If this is a bit beyond you, I'd suggest learning a bit about vector maths. Bullet is not easy to use without a bit of understanding of the basic maths.

Share this post


Link to post
Share on other sites

Best of luck. I found this unsolvable. Its a shame as on flat surfaces, you can get away with using a rigid body as a character controller fairly well, but the slope sliding is a deal breaker for me.

 

Bold part makes me unhappy.

Luckily i did not scrap kinematic ctrl. so i can always go back.

Although currently its fine as it is for my needs.

Share this post


Link to post
Share on other sites

 

So i tried kinematic character controller from bullet physics and i don't have a problem yet. I used the code from characterdemo of bullet physics and managed to walk in the direction where player is looking, but there is no code in the demo for moving left or right. How can i achieve this?


You have an up vector and you have the forward vector. Do a cross product on these to get the right vector. Then just move the controller by multiples of this vector, either adding or subtracting.

If this is a bit beyond you, I'd suggest learning a bit about vector maths. Bullet is not easy to use without a bit of understanding of the basic maths.

Well i do understand that and i will try it. (I already knew that cross product of two vectors yields another vector which is perpendicular to both vector. I just didn't knew how to let bullet know that i want to move left or right.)

 

EDIT : I got it working, thanks.

Edited by newtechnology

Share this post


Link to post
Share on other sites

Such a timely post!

 

I too would like to get some character controller working out of the Bullet Physics Engine.

 

I am currently trying the KinematicCharacterController but as others said it is a mess; I have a log of static mesh loaded via btBvhTriangleMeshShapes but either that doesn't work well with the KinematicCharacterController, I am doing something wrong, or who knows what.

 

I'd love to hear how people are implementing their own Character Controllers.

 

Specifically, how are people walking up steps?

 

Thank you for your time.

Share this post


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

  • Advertisement