It’s hacky, to say the least. Tampering with forces or velocities… I’d rather just suspend Dynamics then.
Anyway, I used this technique with a 3D platform demo some time ago, and it just doesn’t work like it should in every situation. For example, you would have to tweak it so much so with slippery slopes the player would slide naturally. I just don’t like it.
maybe have an other material assigned to just the faces of the slop and a collision sensor set to that material to change the forces or whatever to compensate for the different friction.
I think the best way to prevent the sliding is casting a ray downwards to check if the player collides with the ground.
If it collides with the ground AND no movementkeys are pressed then set the velocity to 0.
The problem with that is that you have to make sure that the ray or collision box beneath the player should be as small as possible, so the player wouldn’t stick to the ground every time it jumps. So when jumping, the player is higher then the length of the ray in one logic tic.
Are you using the servo motion actuator? I usually set the force limits to about 9.0/-9.0 on all axis and set linV to zero if no buttons are pressed. That will glue your player in place no matter what. Reducing the z force limit to near zero when moving will allow falling and jumping as normal.
For the logic brick setup use two actuators, one with an “and” controller and the other with a “not” controller linked to the keyboard sensor.
I actually use python for every other function apart from this one because i havent found a python script that betters it.
It automatically chooses the correct force to make sure your object moves the amount you want, overcoming friction and collisions to do so.
I don’t actually recommend using unlimited force as I did in the demo. As your character is unlikely to have to climb such steep slopes, and if they did, they should struggle a bit right?
Something more like this may work better:
Sorry but, why are we resorting to using python and logic bricks to solve this issue?
Wouldn’t increasing the friction property in the material settings pretty much fix the problem?
I’ve been using this method to fix issues like this for a long time now…
The extra logic calculations is just going to slow down the game in the end.