Help with sliding character controller

Post Reply
Ancalagon
Posts: 3
Joined: Wed Aug 08, 2012 5:32 pm

Help with sliding character controller

Post by Ancalagon »

Hi guys,

I have a character controller and it is sliding down slopes. I know this question gets asked a lot, so please dont just say use the search function - I have searched using google and not found anything helpful.

For reference, these are the threads I have tried to mine for useful information:
http://bulletphysics.org/Bullet/phpBB3/ ... php?t=5039 (no help because he is using a rigid body)
http://bulletphysics.org/Bullet/phpBB3/ ... php?t=8220 (mentions he fixed the sliding problem by setting friction to a high value - friction is set to 100.0f on both the ghost object and the terrain and this does nothing to stop the sliding)
http://www.bulletphysics.org/Bullet/php ... f=4&t=2665 (sounds like he used a rigid body instead of a character controller but overcame the issues associated with it)
http://irrlicht.sourceforge.net/forum/v ... =4&t=39433 (friction again, doesnt work for me)

So you see, I have tried to do a bit of reading, but cant find anything useful. Does anyone have useful tips for me?

What I have tried:
Setting friction on my ghost object and bvh triangle mesh shape really high. Nothing.
Comment out step up: character goes flying
Comment out step down: character goes flying
Comment out the line where current position is interpolated from the values of the callback in stepDown. Result: character jitters, and still slides down the slope, only much slower.
Restore the original X and Z, or Y coordinate in current position after interpolation. Result: Nothing. I think restoring the Y coordinate produces a result similar to above.
Change the max slope angle to 75 degrees (nothing) or 5 degrees (cant walk up slopes anymore)
Comment out the interpolation step in stepUp - nothing happens.

I think what is happening is that the Y coordinate changes in stepDown, and this new y coordinate causes the X and Z values to change in a later step or update cycle. But I dont know where. I'm tearing my hair out trying to get this to work. I'm surprised that friction does absolutely nothing, I expected it to have some effect.

Can anyone help?

I am using simple box shapes for the characters and a bvh triangle mesh shape for the terrain. All slopes are 45 degrees, and the characters (and thus box shapes) remain upright while standing on a slope.
bcsanches
Posts: 10
Joined: Mon Feb 02, 2009 2:15 pm

Re: Help with sliding character controller

Post by bcsanches »

There is a method for controlling the slope of surfaces that character will slide or stick too:

setMaxSlope(btRadians(45.0));

The default is 45 degrees, so anything bigger than 45 will make your character slide down. Just increate the value.

My 2 cents.

Best Regards
Ancalagon
Posts: 3
Joined: Wed Aug 08, 2012 5:32 pm

Re: Help with sliding character controller

Post by Ancalagon »

Hi,

Tried that, didnt work.

What it eventually turned to be was actually recoverFromPenetration. I think it had something to do with the fact I was using a box shape. I am now using a capsule shape, but I think the same thing would happen.

My theory is that stepDown would cause the height of the ghost object to drop slightly. When recoverFromPenetration was next called, it would discover that the collision shape was now intersecting the terrain, and shift it outwards, instead of back up. So it would gradually move down the slope.

I've disabled recover from penetration for now. It results in behaviour that suits me. If further testing uncovers a need for it, I'll find a way to integrate it without the sliding.
Post Reply