I’ve tried to describe the issue in this image:
I can’t think of any additional information that I could/ should post, but of course I’ll provide more if needed.
…also, a brief text-only description of the issue in case you can’t access the image:
Essentially I’m changing the friction of a 2D physics material assigned to all 2D colliders of my character based on a boolean variable called ‘grounded’. ‘grounded’ is true if a 2D overlap circle (at the feet/ base of the character) detects any other colliders (excluding the character colliders, they’re on a different layer). It works fine (I use it for animations and the jumping mechanics), so I don’t think it’s related to the issue.
Anyway, the important piece of code is
// Set friction
if ( grounded == true ) {
cat_physics_material.friction = 0.6;
}
else if ( grounded == false ) {
cat_physics_material.friction = 0f;
}
‘cat_physics_material’ being the 2D physics material.
The change of frictions shows up fine in the inspector, but the actual, in-game friction is different. So, even though the friction displays as 0 in the air (grounded == false), the friction seems to be 0.6 (character gets stuck in wall and doesn’t fall to the ground, grounded remains false since the overlap circle doesn’t collide with walls). On the other hand, when landing on the ground, while frictions shows up as 0.6, the character slides on the ground completely frictionless.
If I comment the snippet of code out and set friction to either 0 or 0.6, everything works as expected (it’s just that I need the friction to change).
I somewhat expect me just missing an option to enable or something, but yeah; I can’t really figure this one out myself so help’s certainly appreciated!
