How to automatically rotate the player perpendicular to wall normal?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By eayst

I want to make the player rotate on the y-axis perpendicular to the wall normal when wall running. For example, if the player holds forward key to wall run on a cylinder, the player will always face forward and keep running around the cylinder without falling off. The same effect can be found in Titanfall 2 when you wall run on curved walls.

In example picture, red rectangles represent how I want player (white rectangle) to automatically rotate as they are wall running round the cylinder:

Relevant wall run code:

I’m stuck on how exactly to use the wall_normal to adjust y-axis rotation of player. Other methods are also okay. I’m new to Godot, please help, much appreciated!

Use gravityvec.x =gravityvec.x-10

In physics process it will pull you toward x axis your character

Sharda | 2022-12-21 09:46