Launched in opposite direction when colliding exactly on an edge
Zephni opened this issue · 0 comments
I have been having some trouble when the collider lands exactly on an edge (eg a 135 degree angle like below):
It happens maybe 1 in 5 times as it's not exactly easy to hit the precise spot that breaks it, but when it happens it launches the player in the opposite direction, I have tried playing with the number of rays, and the skin width and all sorts but in the end I made a simple adjustment that seem to fix it.
On line 470 of CharacterCollider2D.cs add "return false;" within the handleHorizontalSlope method:
else // too steep. get out of here
{
deltaMovement.x = 0;
return false;
}
At the beginning of this method it will simply return false if the wall is greater than 90 degrees, but otherwise it checks some variables, does some deltaMovement work and returns true regardless of whether the slope still over the threshold that the user sets in slopeLimit
It seems to work for me now I have added it. Maybe someone else has experienced this issue and hopefully this helps.