CharacterController and Bounciness property

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Skwerl
Posts: 3
Joined: Thu Apr 09, 2009 3:03 am

CharacterController and Bounciness property

Post by Skwerl »

I'm using the CharacterController for my player object. It collides with my static triangle mesh level with only infrequent incidents where the character gets stuck in the ground for a fraction of a second after an especially high jump. I would like my character to bounce a bit when it hits the ground, so I have increased the bounciness property on the CharacterController's bodyshape. When I drop the player onto the level, the first bounce always works. However, with subsequent jumps or falls, the bounce very rarely happens. I've verified that the bounciness property never changes throughout the simulation, so I am wondering if there is something else hindering the bounce. Any suggestions are appreciated!

Thank you,
Josh
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: CharacterController and Bounciness property

Post by Norbo »

The subsequent hits probably don't get the body shape into contact with the ground, so there's nothing to bounce off of. Part of the character controller's job is to keep the body elevated some amount off the ground (which can be violated by hitting the ground with a large velocity since the body shape undergoes continuous detection, not the character controller's detection systems). If you want reliable bounciness, you'd need to implement as part of the character controller. This would be done after the relative velocity of supports and character body have been computed. Using the relative velocity and the supporting normal you can determine the bounce velocity.

It would be something like this (where bouncinessFactor is a value from 0 - 1 like an entity's bounciness):

relativeVelocity dot normal = relativeNormalVelocity;
bounceVelocity = bouncinessFactor * -relativeNormalVelocity;

That velocity could then be applied to the character's body in some way. You'd probably also want to keep it from bouncing all the time by only bouncing when the relative normal velocity is sufficiently high. There's an isAirborne flag in the character controller that needs to be set as well after you bounce.
Skwerl
Posts: 3
Joined: Thu Apr 09, 2009 3:03 am

Re: CharacterController and Bounciness property

Post by Skwerl »

Ah! That makes sense. Okay, I'll get in there and make the modification. Thanks for your help!

Josh Usovsky
Post Reply