Fixed bug that caused the player to automatically hop onto slimes and… #531
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses issue #426.
To fix it, I changed the colliders on problematic objects like slimes and small bushes from sphere colliders to box colliders. I downsized the box colliders to be slightly smaller than the actual object so as to make it as functionally close to a spherical collider as possible. This removes the possibility for the player to slide up the sphere's upper slope when moving too close to it. I also added some fail-safe code at the bottom of Protagonist.cs, where I check the distance between the player and bush/critter objects (identified by appropriate tags in Unity) to see if the objects are clipping (i.e. their colliders are overlapping), and lerping the player just outside of the object's collider if so.
Here are two videos demonstrating this fix, one where I try running up on, walking up on, and hitting bushes from different angles, and another where I do the same to a slime. In both videos and all my testing, I was unable to replicate the bug as before.
https://user-images.githubusercontent.com/73858910/233741891-dd266818-7946-45e8-86d4-f967283f76c7.mp4
https://user-images.githubusercontent.com/73858910/233741901-c83170f8-455b-4d0b-9f6d-15757e3639b7.mp4