Page 1 of 1

Character Controller - Awkward Movement

Posted: Mon Sep 06, 2010 8:24 pm
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.

Re: Character Controller - Awkward Movement

Posted: Mon Sep 06, 2010 8:36 pm
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.

Re: Character Controller - Awkward Movement

Posted: Mon Sep 06, 2010 9:26 pm
by chronicacid
That worked! Thank you.