How to Detect Adjacent Faces on Static Mesh Using C++?

I’m developing a game in Unreal Engine 5, and I need to create a spider locomotion system that allows the character to walk seamlessly on all surfaces, including walls and ceilings. Here’s what I’m aiming to achieve:

Detect the specific face of a static mesh that the spider is currently standing on.

Determine which faces of the mesh are adjacent to the current face.

Move the spider smoothly from one face to another, adjusting its gravity and rotation to align with the angle of the face.

Ensure the transitions between surfaces (e.g., from floor to wall, or wall to ceiling) are fluid and natural.

I’ve considered using line traces to detect surface normals and face information, but I’m unsure how to handle face adjacency.

What is the best way to approach this problem? Should I calculate adjacency data offline (e.g., in a modeling tool) or is there an efficient way to do it at runtime in Unreal Engine? Any advice would be appreciated.