btKinematicCharacterController fundamentally broken?

Post Reply
dizzy
Posts: 1
Joined: Thu Mar 01, 2012 5:05 am

btKinematicCharacterController fundamentally broken?

Post by dizzy »

(Bullet 2.79 rev 2440)

I realise btKinematicCharacterController is marked as experimental, and it seems like there's no project file for the demo code provided.

But I went ahead and used it anyway, and got the demo code running.

here's the issues I've seen so far.

In the demo

1. No step up, even the demo code wont actually stepup up the majority of the steps whatever I set the max step to
2. The character jitters significantly if you run diagonally along a wall, or directly into it (the demo moves very very slow by default a more reasonable speed makes the jitter more obvious)
3. Even though the comments say the character wont interact with dynamic objects it does seem to push them about

In My own test code (a rigid body shape box of mass 0- i.e static for floor, with a static box for a wall, and a few play objects a dynamic box and sphere)
all the above issues plus

1. If the floor is a slope the character slides down it (well more sort of jitters its way down the slope) rather than remaining stationary (whatever the max slope is set to)
2. Vertical jitter just when at rest on the floor.
3. if I stand on the edge of a dynamic box (by jumping onto it) one corner of the dynamic box gets pushed through the floor and then flies off when it tries to un penetrate.

screenshot of my demo world http://dl.dropbox.com/u/10491373/charac ... roller.png

So is anyone actually successfully using btKinematicCharacterController? Or is everyone implementing their own character controller? Or do I have a myriad of bugs of my own making somehow.
MaxDZ8
Posts: 149
Joined: Fri Jun 24, 2011 8:53 am

Re: btKinematicCharacterController fundamentally broken?

Post by MaxDZ8 »

I have quite some doubts about kinematic objects in general. See Getting the rid of kinematic objects. While using the Bullet library makes many things much easier, a lot of stuff becomes complicated in the moment we add dynamics to it. I suppose it's the price to pay for simulation.
I've myself observed problems you mention {demo 1 and 2}. After some experimentation, I had to give up to the idea kinematics are only good for "non-physics" entities, often referred as "func trains", "platforms" or whatever.
How to go upstairs is, at this point, pretty much of a mystery to me. Perhaps it would be better to just have slopes instead, albeit this would cause quite some divergence in physics simulation. I cannot see any viable way to make dynamic-driven objects go upstairs.

As for problem {demo 3} this is correct behaviour. My understanding is that kinematics won't cause collisions against dynamics or even statics but they cause encroaching. Therefore, the kinematic object pushes dynamics around by the means of resolving encroaching and this is - I suppose - the reason causing kinematics to push stuff less than they should.

Regarding your questions.

I am not using btKinematicCharacterController. I initially rolled my own controller as my current project required relatively simple management. I still have some issues and I had to switch to a dynamic-based method. I am lucky this is actually possible given my current art, I have no idea how to make this work in general. Stairs are scary.

I'm afraid we could only figure this out ourself by collecting link and articles.
aymar.fisherman
Posts: 9
Joined: Mon Jul 04, 2011 6:18 pm

Re: btKinematicCharacterController fundamentally broken?

Post by aymar.fisherman »

I've implemented my own version of the KinematicCharacterController and it's working perfectly!
I've dedicated some time on re-writing a lot of methods (and algorithms) from the btKinematicCharacterController (for optimization, adaption and correction).
Now my character slides down slopes, doesn't jitter when running against walls (actually it slides smoothly), doesn't climb slightly inclined walls, go upstairs (and downstairs), doesn't send objects flying away when standing over them and it doesn't have any of those movement flaws that the btKinematicCharacterController have.

A lot of good reasons to use Kinematic Character Controller and not Dynamic Character Controller can be found here:
http://www.digitalrune.com/Support/Blog ... llers.aspx

Sadly, I can't share my character controller code, but I can share the logic of it's implementation (and maybe some code snippets), just ask!
MaxDZ8
Posts: 149
Joined: Fri Jun 24, 2011 8:53 am

Re: btKinematicCharacterController fundamentally broken?

Post by MaxDZ8 »

Thank you for sharing. One of the issues I had is that I needed physics simulation for kinematically controlled objects to match dynamic objects. Do you have this issue?
aymar.fisherman
Posts: 9
Joined: Mon Jul 04, 2011 6:18 pm

Re: btKinematicCharacterController fundamentally broken?

Post by aymar.fisherman »

I actually don't want my character physics to match dynamic objects physics.
The way a character should behave is far from the rigid body physics used in dynamic objects.
So, you just have to implement only the physics that you actually want to apply in your character.
I've only implemented gravity and CCD for my character, it's way better than setting my character as a rigid body and disabling almost every calculation done for rigid bodies (restitution, friction, inertia, etc).

The link in my previous post explain why a character physics shouldn't match rigid body physics.

So, unless your character really is a rigid body (like a sphere, or a cube and not a humanoid), i'd recommend implementing your own kinematic controller.
MaxDZ8
Posts: 149
Joined: Fri Jun 24, 2011 8:53 am

Re: btKinematicCharacterController fundamentally broken?

Post by MaxDZ8 »

Thank you very much. I think I get your reasoning. Have you deployed anything to save on sweep tests for the CCD?
I don't really need the object to behave the same way, but I need it to be affected by gravity and other forces in the same way as a dynamic. At its simplest, it needs to "fall" in the same way as a dynamic until a bounce. Do you have any suggestions?
aymar.fisherman
Posts: 9
Joined: Mon Jul 04, 2011 6:18 pm

Re: btKinematicCharacterController fundamentally broken?

Post by aymar.fisherman »

I actually used some additional sweep tests, it's not a bottleneck for me.

And my suggestion would be to apply the gravity manually in each simulation tick, 'cause this way you can tweak it and make it exactly the way you want it!

Character Controllers should be very simple to understand and tweak, this way you'll be able to make your character behave exactly the way you want to!

I'd also suggest learning the logic behind the default btKinematicCharacterController and then implementing your own version (and try to make it simple, functional and clean). Maybe this way you'll spot the flaws in the btKinematicCharacterController and you'll be able to correct those flaws and make a very good controller!
yavol
Posts: 1
Joined: Thu May 03, 2012 11:53 pm

Re: btKinematicCharacterController fundamentally broken?

Post by yavol »

aymar.fisherman wrote:I've implemented my own version of the KinematicCharacterController and it's working perfectly!
Now my character ... doesn't jitter when running against walls (actually it slides smoothly)

Sadly, I can't share my character controller code, but I can share the logic of it's implementation (and maybe some code snippets), just ask!
The jitter problem is very interesting. Could you please advise as to how you approached it? Are there any links?
DannyChapman
Posts: 84
Joined: Sun Jan 07, 2007 4:29 pm
Location: Oxford, England
Contact:

Re: btKinematicCharacterController fundamentally broken?

Post by DannyChapman »

Dennis Gustafsson made an interesting, slightly (but not hugely!) relevant, post recently:

http://tuxedolabs.blogspot.co.uk/2012/0 ... jumps.html
dumbo2007
Posts: 66
Joined: Sun Jan 30, 2011 8:46 pm

Re: btKinematicCharacterController fundamentally broken?

Post by dumbo2007 »

I am interested in the logic !

I am just beginning to go through the character controller code, any input would be most helpful :)
rob
Posts: 1
Joined: Sun May 27, 2012 11:52 am

Re: btKinematicCharacterController fundamentally broken?

Post by rob »

I have just started playing with the character controller this weekend and also noticed some issues when implementing it.

I will share my findings so that it might help others. I hope more people will also share theirs.

Some issues mentioned ( sliding down slopes etc ) in my case came from the fact that the btKinematicCharacterController is a bit too aggresive when recovering from penetration.

This can easily be seen by outputting the recovery vector in recoverFromPenetration in btKinematicCharacterController.cpp

Code: Select all

btVector3 recoverDir = pt.m_normalWorldOnB * directionSign * dist * btScalar(0.2);
printf("recoverDir=%f,%f,%f\n",recoverDir[0],recoverDir[1],recoverDir[2]);
Even standing on a flat tri-mesh would continuously trigger recovery ( but less noticable when not outputting any debug on the recovery )... and when standing on a slope you will get pushed off because no margin was added for penetration recovery.

A quick fix for this is to add a margin to the recovery

You can change the following

Code: Select all

btScalar dist = pt.getDistance();
if (dist < 0.0)
into

Code: Select all

btScalar dist = pt.getDistance();
if (fabs(dist) > 0.2 /* m_addedMargin? */)
That will atleast fix the continuous penetration recovery and you will no longer get pushed of slopes.

Besides that there is also another "issue" in the stepForwardAndStrafe routine... basically when walking into a slope, with an angle you should not be able to climb, it will calculate a perpendicularComponent based on the collision so that you will strafe/slide along a wall / geometry which is steeper then the max slope angle.

The issue with this is that the perpendicular vector of the collision will also move the character on the y-axis eventhough you are not able to climb the geometry which could result in jitter because of needed recovery after this movement.

When walking into a very steep hill i got:
perpComponent=0.062345,0.075178,-0.084877

Which will let the character slide along the hill as expected but will also every now and then push it up a bit and penetrate geometry and thus it needs to recover which resulted into a bit of jitter.

For now i have "solved" this by setting the y-component to 0. This is pretty dirty and might lead to other errors ( havent had time to do any real testing ) so better is to create a proper fix ( which i think should take the max slope angle into account and possibly check if you are on the ground? ).

in updateTargetPositionBasedOnCollision:

Code: Select all

		if (normalMag != 0.0)
		{
			btVector3 perpComponent = perpindicularDir * btScalar (normalMag*movementLength);
                        perpComponent[1]=0.0f;
//			printf("perpComponent=%f,%f,%f\n",perpComponent[0],perpComponent[1],perpComponent[2]);
			m_targetPosition += perpComponent;
		}
As i said i just started playing with the character controller so if someone has better ways to fix some of the issues please let me know.

Besides these issues the character controller does a pretty good job and i dont think that most other issues are hard to fix.

P.S.:
Im dutch so please dont mind my english.
Post Reply