Fixed loading screen UI bug when aspect ratio is 21:9 or similar ultr… #529
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 both issues #426 and #518.
For #426, 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.
For #518, I made a new script, UIScaling.cs, and attached it to the Canvas object which contains the loading screen. In this script, I gets the screen's width and height, and readjust the canvas size to reference this size and scale to it, so that it works for any resolution.
Here are two videos demonstrating the fix for #426, 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/233730332-5c8a69ab-3be9-48ea-9b59-b79478e1eeaf.mp4
https://user-images.githubusercontent.com/73858910/233730349-cf34f59a-d895-4802-b96f-00fd8ec89677.mp4
Here is a video demonstrating the fix for #518, where I load the loading screen in first 16:9 aspect ratio, then 21:9 aspect ratio, then 21:5 aspect ratio. For all ratios, the loading screen looked the same, demonstrating how it now scales properly for all kinds of displays.
https://user-images.githubusercontent.com/73858910/233730873-6759e569-04e2-4eb2-81ea-d0f3de290bcb.mp4