Character Controller - Awkward Movement

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
chronicacid
Posts: 12
Joined: Sat Jul 10, 2010 5:19 pm

Character Controller - Awkward Movement

Post by chronicacid »

There's a problem with the character controller class I'm having.

I'm using the xbox game pad. When I press forward the character moves forward - but when I try to switch directions (eg, flick suddenly backwards) - the character loses traction on the floor and skids a second or 2 then regains traction and moved the opposite direction.

The weird part is if I press forward and it's going forward full spreed - and then I let go of controller - The character stop's perfectly.

Any idea what's happening. I can be more descriptive if you need me to be.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Character Controller - Awkward Movement

Post by Norbo »

The character controller uses its Acceleration field to reach new desired speeds, but uses its TractionDeceleration field to stop unwanted motion. When you stop moving, it uses TractionDeceleration. When you flip movement directions, it uses Acceleration instead. By default, TractionDeceleration is higher than Acceleration, so you see a bit of a difference. If they are equal, there would be no difference.

You could change this behavior entirely if you'd like by modifying the HandleHorizontalMotion method in the CharacterController. In the part that computes and applies the velocity change, you could add some extra logic to see if the current netZVelocity is negative, and if so, use TractionDeceleration instead of Acceleration.
chronicacid
Posts: 12
Joined: Sat Jul 10, 2010 5:19 pm

Re: Character Controller - Awkward Movement

Post by chronicacid »

That worked! Thank you.
Post Reply