How do you make something always rotate away from a surface normal?

I want to tilt the camera away from the wall in the direction you’re touching against it. How do I do that?

I’ve set it up so when the character hits an actor tagged as wall it gets the surface normal, and hit location but I can’t figure out what to do from there.

I tried using the hit location and a component placed on one side to get the distance between the two but that all goes out the window if the character is closer to directly facing the wall or with his/her back to the wall.

I was thinking of using line traces in each direction or trigger components placed on each side of the character but isn’t there a mathematical way to do this? the line traces idea especially seems expensive

Are you using blueprints or c++

blueprints

So if I understand your question correctly you want to rotate the camera away from a wall when you physically run agains it.
Your trace idea isn’t that bad but is pretty expensive as you said so I would recommend to add a collision component like a sphere or something and then add an event on it (OnComponentBegin/EndOverlap) and then do this:

Note that you need to make sure that the wall can be ovelaped