Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launched in opposite direction when colliding exactly on an edge #112

Open
Zephni opened this issue Oct 3, 2021 · 0 comments
Open

Launched in opposite direction when colliding exactly on an edge #112

Zephni opened this issue Oct 3, 2021 · 0 comments

Comments

@Zephni
Copy link

Zephni commented Oct 3, 2021

I have been having some trouble when the collider lands exactly on an edge (eg a 135 degree angle like below):

image

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant