Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Bullet physics character


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
14 replies to this topic

#1 newtechnology   Members   -  Reputation: 857

Like
0Likes
Like

Posted 09 June 2014 - 01:38 AM

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, 09 June 2014 - 01:39 AM.


Sponsor:

#2 MARIO_H   Members   -  Reputation: 119

Like
0Likes
Like

Posted 09 June 2014 - 02:46 AM

Take camera forward direction  vector and setLinearVelocity with it.



#3 Aardvajk   Crossbones+   -  Reputation: 7972

Like
0Likes
Like

Posted 09 June 2014 - 03:35 AM

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.



#4 Enhex   Members   -  Reputation: 121

Like
1Likes
Like

Posted 09 June 2014 - 06:40 AM

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.



#5 MARIO_H   Members   -  Reputation: 119

Like
1Likes
Like

Posted 09 June 2014 - 07:28 AM

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:

http://youtu.be/BQ9Lg4Em0r0


Edited by MARIO_H, 09 June 2014 - 07:41 AM.


#6 Enhex   Members   -  Reputation: 121

Like
0Likes
Like

Posted 09 June 2014 - 11:18 AM

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



#7 Aardvajk   Crossbones+   -  Reputation: 7972

Like
0Likes
Like

Posted 09 June 2014 - 12:40 PM

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:

http://youtu.be/BQ9Lg4Em0r0

 

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.



#8 Aardvajk   Crossbones+   -  Reputation: 7972

Like
0Likes
Like

Posted 09 June 2014 - 12:42 PM

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.



#9 MARIO_H   Members   -  Reputation: 119

Like
0Likes
Like

Posted 09 June 2014 - 04:04 PM

 

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:

http://youtu.be/BQ9Lg4Em0r0

 

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.



#10 Aardvajk   Crossbones+   -  Reputation: 7972

Like
0Likes
Like

Posted 10 June 2014 - 05:36 AM


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.



#11 newtechnology   Members   -  Reputation: 857

Like
0Likes
Like

Posted 10 June 2014 - 11:01 AM

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?

#12 Aardvajk   Crossbones+   -  Reputation: 7972

Like
1Likes
Like

Posted 10 June 2014 - 12:37 PM

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.



#13 MARIO_H   Members   -  Reputation: 119

Like
0Likes
Like

Posted 10 June 2014 - 12:41 PM

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.



#14 newtechnology   Members   -  Reputation: 857

Like
0Likes
Like

Posted 10 June 2014 - 11:50 PM

 

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, 11 June 2014 - 12:20 AM.


#15 tmason   Members   -  Reputation: 326

Like
0Likes
Like

Posted 13 June 2014 - 11:02 PM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS