Camera rotation for spider, related of surface

Hi everyone! I’m newbie here, if someone could help me or give any ideas to resolve a problem, I’ll be very grateful :folded_hands:

Spider has movement WASD, but AD is just only for strafe, cause I use mouse X for rotating (I use control rotation yaw multiplying IA move to create vector for movement direction) + of course traces to detect uneven surface.

But on the walls I also want the camera to rotate so it matches the surface. When spider reaches the wall (on gif) it started rotate in another direction and kinda stuck there, I think because of cross product of control rotation.

019

From that video https://www.youtube.com/watch?v=xTZAG2VdMrM I figured out it might be better to create flat surface under uneven one. Use flat for camera direction and uneven for mesh tracing :thinking: