In my game, the player moves using velocity until they run into a collider (Up, down, left or right). They cannot redirect their movement once moving. However, if they are directly touching a collider, they can move into it (again) and get “stuck” in the wall, unable to move again because it reads as moving.
Using a Raycast does not seem to work because if the player is already touching a wall, their collider is already slightly inside of it and it seems to ignore the collider. Currently, I am using a bool to check whether or not the player just moved in a specific direction, essentially preventing them from moving in the same direction 2 times in a row. However, if they run into a corner, this problem can still occur.
Is there any way to check the direction of a collision? Or a simple solution to this problem? I am in the process of learning C# and would greatly appreciate some assistance. Thanks in advance!