Page 1 of 1

Stop Entity from Sliding

Posted: Fri Jun 07, 2013 6:24 pm
by Spykam22
Hello!

How would I keep an Entity from sliding? I want the player to be able to move then immediately stop when they release the button. I'm moving it by adding to LinearVelocity's X and Z value. I tried changing Kinetic and Static Friction, but I keep sliding. How would I stop the player from sliding as soon as the button is released? Thanks!

Re: Stop Entity from Sliding

Posted: Fri Jun 07, 2013 6:30 pm
by Norbo
Setting an object's linear velocity to zero will instantly stop it.

If the object in question is supposed to behave like a character, you may end up with better behavior by using the CharacterController. It has the usual FPS-style control with configurable speeds/accelerations, among other things.

Re: Stop Entity from Sliding

Posted: Fri Jun 07, 2013 6:59 pm
by Spykam22
Hello!

I tried using CharacterController (had to try to port it) and after I thought I was done, 200 more errors came up lol. How does the character controller deal with sliding and friction?

Thanks :D

Re: Stop Entity from Sliding

Posted: Fri Jun 07, 2013 7:42 pm
by Norbo
It has a 'HorizontalMotionConstraint' which supports maximum speed and acceleration properties for different character states. While you could create a system which handles maximum speed and acceleration with just direct linear velocity modifications, the constraint is more robust because it properly interacts with dynamic support objects and handles some other corner cases (e.g. sliding on slopes or in rotating frames of reference).