I can detect which side of an object I collide with however I need to reset some variables when I exit a collision. How do I tell which side of an object I exited from? (ie if I have collided with the ground then I collide with a wall on the left but then move right I need to know if I have exited from the collision with the wall or if I exited from the collision with the ground.)
Note the blocks I am colliding with are both walls and ground so I can't use layer names etc.
I really struggle to understand the question, but a common trick is you actually have a number of colliders on the object.
Say it is a cube.
Instead of having one cube-shaped collider, in fact have SIX colliders!
(So, basically flat ones, whatever technique you want to use.)
Depending on your situation, you then know exactly what collided with what.
I really don't understand the question, but I think you're wanting to know, of the six, which was the "last one" touched.
Of course, that is easy to achieve as a basic programming matter, just figure out which of the six was touched last.†
Note that as BugFinder explains. As you "leave", simply look at your new velocity, that is to say look at the direction of your velocity.
Obviously, that will instantly tell you "what part" of the other object, you must have bounced off.
Note too that indeed you can simply cast backwards from your new velocity, and see what you hit - that is likely what bounced you!
--
† beware that PhysX can matt things in to the same frame, the idea of what was "touched last" when you're in a corner can be problematic. This is why "2" is a common approach.