Friction doesn't work

kosob
Posts: 2
Joined: Tue Jul 14, 2015 9:31 pm

Friction doesn't work

Post by kosob »

Hello,
I have a problem with friction using my simple character controller.

Character controller is as follows:
- dynamic ridig body with capsule collision shape,
- disabled angular motion (no inertia tensor),
- on key press setting linear velocity to some vector (say (1, 0, 0)),
- scene/ground is created from simple static box with no mass,
- both have assigned huge amounts of friction which doesn't work (tested various values with no luck).

The result is if I set some linear velocity my character keeps sliding forver with no friction (actually the velocity seems to slightly gain but it's neglible so it might be floating point inaccuracy).

I must be missing something obvious because I know this was working in the past but after some refactorings, code erosion and some period of stagnation things got broken and now I'm trying to figure out what.

The gravity, collision and everything except that works just fine.

I potentially *could* use linear damping but that would also affect character while in midair, and I want to avoid that and basically do it the *right* way.

Any auggestions?
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Friction doesn't work

Post by Basroil »

Have you tried checking the collision points to verify they don't change? One of the known issues with most physics engines is minute collision point changes adding unbalanced restitution "forces". You can also try seeing if a sphere shape (instead of capsule) and box works as intended, since the shapes should not have as many issues in the conditions you listed.
kosob
Posts: 2
Joined: Tue Jul 14, 2015 9:31 pm

Re: Friction doesn't work

Post by kosob »

I figured it out. Silly me - my recent player initialization now goes through scripts and that by default calculates inertia tensor for dynamic objects and it just needed overriding in this case. Switching to TPP camera revealed that the the capsule was just rolling all along :). Using box shape in FPP gave me the clue that there's friction (box started to jump and roll because of the friction) so that was useful tip.

Thanks a lot!
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Friction doesn't work

Post by Basroil »

When it doubt, box it out :wink: