Best way to make player Parallel to walls?


at this point, i believe that checking the player’s transform.right and aligning it to the normal of the surface is the best way to do this. how should i go about doing this?

Attached is a picture that mostly demonstrates what it is im looking for for the most part, the player jumps and hits the wall an angle, the player is then rotated to be parallel with the wall.92715-unity-problem.jpg

and while ive tried setting the players rotation depending on which angle it was rotated at upon triggering the wallrun, that is extremely tedious because the player has walls to run on that are basically cylindrical (which is why the picture is mostly accurate) and the rotation of the player needs to follow the curve as it changes.

what is going to be the best way to match the players left or right side to the current normal the player is attached to?

found it. i ended up using

                if (Physics.Raycast(transform.position, -transform.right))
                    transform.rotation = Quaternion.FromToRotation(Vector3.right, hit.normal);
and this for the opposite side

                if (Physics.Raycast(transform.position, transform.right))
                    transform.rotation = Quaternion.FromToRotation(-Vector3.right, hit.normal);

this only triggers upon the collision of the wall so from what i can tell, its not very taxing overall