Stop the Player from sliding down the slope /
Uhh. Two evenings and gazillion nerves...
Situation: The PlayerObject moves allright. But! If he stops on an any kind of slope, the physics make him slide down, which is, of course, how physics work, but are not needed in this particular gameplay.
I've tried so many things, that now my brains boil. Also minimizing Gravity force doesn't help, as then, if stepped over the ledge, PlayerObject start to float. Tried "if (!Input.anyKey)" and freeze position - no dice. As extra problem, steep slopes makes the PlayerObject to move upwards considerably slower. Which aso makes sense in the real world, but not needed here.
Dear gurus! Any ideas? Beer on me.
Answer by xxmariofer · Feb 03, 2019 at 11:48 PM
hello, have you tried creating a physical material to the ground and setting the static friction really high?
No. I figured, that this will create climbing uphill even more slower as it is :]
Shouldnt the climbing be affected with the dinamic friction rather than the static friction? Did you give it a try?
Aye. I added Physical$$anonymous$$aterial2D to the Polygon Collider the Player walking on and this made him stuck even on the flat surfaces. He doesn't slide, but he doesn't move now either :]
Answer by S0nathan · Mar 24, 2021 at 02:37 PM
I don't know if you're still searching for a solution (someone gave you one on a different forum I saw), but I imported the collider of the player and two materials, a normal one and one with high friction. When there is no horizontal input (or when the cat isn't supposed to move if you use a variable for that), the Material of the collider is set to the material with high friction via the sharedMaterial property: colliderName.sharedMaterial = materialName; When the cat's moving again, you just set the material back to the normal one before actually moving the cat.