leaning mechanic raycast

Godot Version

4.3 stable

Question

I’m trying to implement an fps leaning mechanic like in r6 or cruelty squad
I have the basics of changing the positions now the problem is making sure they don’t go inside of geometry whenever they lean. My first thought is to do a ray cast as I could just take the distance between the player and the wall and subtract the transformation by the distance however I’m not particularly satisfied by what the distance gives me (I don’t know if I can explain it well but the subtracting or setting the transformation to that doesn’t solve the issue)
Is it better to use a shape that moves along my pivot and make my pivot move along the shape rather than manage rays?