# How do I align a player's normal, while also maintaining their current look rotation?

My game allows players to walk on walls and ceilings the same as if they were on the ground, this is done by rotating the whole player object to the surface normal, however this causes the player body’s look rotation (which is a child object of the player) to be forced into the direction that the main player object rotated towards. (The screenshots explain it slightly better)

For example, in the screenshot below the player is facing towards the right, but once they walk over the arch/bend, they are forced to be looking towards the floor.

The player’s forward direction (blue arrow) is facing toward the right

After going over the arch/bend, their forward direction is now facing down.

If anyone is able to give an answer on how to compensate for this forced rotation, or how to prevent it entirely, it would be greatly appreciated, cheers!

Well without seeing your code it’s impossible to say what the cause of this problem is. But in general the key here is to use vector projection and Quaternion.LookRotation, e.g:

``````Vector3 playerforward = player.transform.forward;
Vector3 surfaceNormal = howeverYouGetThis;

Vector3 projectedForward = Vector3.ProjectOnPlane(playerForward, surfaceNormal);
Quaternion desiredRotation = Quaternion.LookRotation(projectedForward, surfaceNormal);
player.transform.rotation = desiredRotation;
``````
1 Like

Legend! It works perfectly now, my bad for not showing the code, all I did was just get the surface normal from a rayhit and align the player’s up direction to that.