Is there a working kinematic character controler

Pacha
Posts: 26
Joined: Sat Jun 15, 2013 2:29 am

Is there a working kinematic character controler

Post by Pacha »

Hello everyone. Bullet's kinematic character controller is really poor and I spent more than a month trying to make my own, with no luck and having lots of strange bugs like passing through walls, bad slopes, bad seaming between triangles which calculate wrong normals, etc.

I was wondering if anyone knew of a good implementation of a kcc for bullet that you could share. I already looked at github and some public repositories and found a port of (I think) newton's kcc that has been ported to python, I ported it to C++ but that doesn't work at all.

I use a custom shape as a map (btBvhTriangleMeshShape), and a btCylinder as my character shape.

Thank you very much.
Delbert
Posts: 2
Joined: Thu Jan 16, 2014 1:15 pm

Re: Is there a working kinematic character controler

Post by Delbert »

I can hardly find any source about the Kinematic Character Controller, either.

I wonder whether the KCC's m_character member should be a rigid body. Once the m_ghostObject had a Kinematic Collision Flag, it wouldn't make any collision with rigid body. And the gravity didn't work as it is not a rigid body.

Do you have any ideas?
c6burns
Posts: 149
Joined: Fri May 24, 2013 6:08 am

Re: Is there a working kinematic character controler

Post by c6burns »

You can't have your cake and eat it too. You are either using a kinematic body for your character, in which case you would have to simulate gravity (not very hard), or you are using a non kinematic body and then it is not a kinematic controller. I highly prefer non-kinematic and I believe there is a demo app of a non kinematic character included with bullet. I recommend checking that out.

Also kinematic bodies *do* collide but the effects of such collisions are one way.
Delbert
Posts: 2
Joined: Thu Jan 16, 2014 1:15 pm

Re: Is there a working kinematic character controler

Post by Delbert »

c6burns wrote:You can't have your cake and eat it too. You are either using a kinematic body for your character, in which case you would have to simulate gravity (not very hard), or you are using a non kinematic body and then it is not a kinematic controller. I highly prefer non-kinematic and I believe there is a demo app of a non kinematic character included with bullet. I recommend checking that out.

Also kinematic bodies *do* collide but the effects of such collisions are one way.
I've found a post which made a comparation between kinematic and dynamic character controller.

I would like to use the kcc one.

And the post is here http://www.digitalrune.com/Support/Blog ... llers.aspx.
c6burns
Posts: 149
Joined: Fri May 24, 2013 6:08 am

Re: Is there a working kinematic character controler

Post by c6burns »

From the page you just linked:
The [kinematic] character controller is a dedicated piece of code that uses collision detection routines but no physics library. Physical behavior like gravity, non-penetration of solid objects is implemented explicitly in the character controller module.
You don't get things like gravity (unless you simulate it) or two-way collisions with a kinematic object. It goes where you position it and it affects that which it hits, but nothing affects it.

Also I do not agree with the general conclusion of the article. Perhaps it makes more sense in PhysX, the physics library that it is written about. I've always used non-kinematic characters and animation graphs based on their physical properties like linear/angular velocity, distance from ground, etc. I don't understand why they conclude that you will spend a lot of time disabling features from the physics system you don't want to affect your character ... check out the AppCharacterDemo and DynamicCharacterController. It's done for you.
Aperico
Posts: 7
Joined: Mon Feb 03, 2014 2:15 pm

Re: Is there a working kinematic character controler

Post by Aperico »

Hi, I have been pulling my hair over getting a working character controller the last two days. I have looked at the AppCharacterDemo and DynamicCharacterController (and ported it to the libGDX version of bullet) It works well except the setLinerarVelocity() part.

I use:

rigidBody.setLinearVelocity(linearVelocity);
where linearVelocity is a Vector3 which has the walk direction and I scale it with a constant walk speed. I also tried setting the worldtransform of mostionstate but same results.

I then print the rigidBody.getLinearVelocity() and it matches what I set it too. But I could visually see that the character was moving too slow and even slowed down over time. So I calculated the velocity currentPos.sub(previousPos) / dt and it shows what I visually saw: the velocity is much smaller and starts at random magnitude (I set it to 40 but the real magnitude is anywhere from 35 to 10) then it just gets slower and slower over time. I find it really strange that rigidBody.getLinearVelocity() returns the wrong values, It can be (40, 0, 1) but the character is barley moving. The character also occasionally jerks as if getting stuck. My ground object is a static box and the rigidBody shape is btMultiSphereShape just as in DynamicCharacterController.cpp

Any thoughts about what I could be doing wrong? Any small tip is greatly apprechiated!