Issues with player collision
Author: Aaron King
I'll start this off by saying that it totally slipped my mind that unity caps the frame rate on projects once built. I had gone the entire first few weeks building out a custom collision detection for the player character just so that I wasn't needing to rely on unity to handle the task. It would also give me more access to changing how the collision worked on the back end for greater fine-tuning.
But upon our first build test, not even a member of the team tested, the entire system just stopped working and the PC got stuck in an endless jump cycle. I was trying to take the player's current velocity and predict where they would be on the next frame and if there was no collision detected in that prediction then I would move the player unimpeded to that location. And that worked fine when the game was running at almost 1000FPS, since the movement per frame was so small it gave the ray cast that the player cast in all directions enough time to detect the collision and stop the player. The issue came up when running at a capped 60fps. Since I was only using very short ray casts, about .1 meter, the player was able to move into a wall since the predicted movement had skipped past the wall and not triggered the ray cast.
The solution I ended up coming up with was to combine the custom collision with unity's built-in colliders. Instead of casting 10 rays in all directions of the player, I am now able to cast a single physics box in each direction to detect the collision. I do still use the movement prediction but it is able to perform much faster and stand up to low frame rates. While there are still a few more issues to be worked out, this has been the biggest issue I had to tackle since starting the project, because if you can't move the player, then the rest of the game can't even be played. So keep an eye out for more updates and even more fun traversing the Disavowed world!
Disavowed
Status | In development |
Authors | King Studio, Devon0033, Mike_Sroka, Michael-W-Smith7 |
Genre | Adventure |
Tags | 2D, Action-Adventure, Metroidvania, Unity |
More posts
- Steam Launch!!!Dec 17, 2022
- Coming to a closeDec 16, 2022
- Project OverviewDec 14, 2022
- Steam StuffDec 13, 2022
- Achievement GetDec 11, 2022
- Controls Remapping AgainDec 10, 2022
- Steam funDec 09, 2022
- Boss Music ImplementationDec 09, 2022
- SteamWorksDec 02, 2022
- Callback Issue with Controller SupportDec 02, 2022
Leave a comment
Log in with itch.io to leave a comment.