Child doesnt follow parent's rotation

Hey guys.
As the title says, I’m facing a problem where the player’s mesh, which is a child to the player object refuses to rotate…
To make the mesh face the direction movement I tried using Atan2 which gives me this line of code

	mesh.transform.rotation = Quaternion.Euler(0,Mathf.Atan2(lastDirection.x,lastDirection.z)*Mathf.Rad2Deg,(CS/10)*h);

that works great on plane surface. but when going up or down slops, ( done using ray casting and its the parent that acutally aligns using this:

	rb.transform.rotation = Quaternion.FromToRotation (transform.up, alignhit.normal * Time.deltaTime) * transform.rotation;  

) the mesh refuses to follow the rotation like shown in this picture

As you can tell by seeing the ray, the parent is actually rotating.

What can cause this? And is there a good way to fix it, noting that rotating the mesh to face the direction using LookAt and FromToRotation will also give bad results.
The first causing the mesh to rotate to the side and the other one causes alot of jittering that remains even after going off the slope.

Ive been looking around for a solution for quite alot of time already in vain .___.

Well fixed it.
After reading the API closely I noticed the LookRotation had an optional parameter which was the up reference vector.
So I got rid of euler and switched back to LookRotation adding rb.transform.up as the 2nd parameter and it finally worked perfectly :smiley: