Stop Entity from Sliding

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Spykam22
Posts: 13
Joined: Fri Dec 09, 2011 9:48 pm

Stop Entity from Sliding

Post 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!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Stop Entity from Sliding

Post 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.
Spykam22
Posts: 13
Joined: Fri Dec 09, 2011 9:48 pm

Re: Stop Entity from Sliding

Post 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
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Stop Entity from Sliding

Post 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).
Post Reply