# Align To Normal and rotating player

Hello I am rotating my player using:

Vector3 rotationAmount = Vector3.Lerp(Vector3.zero, new Vector3(0f, rotationDegreePerSecond *
(z < 0f ? -1f : 1f), 0f), Mathf.Abs(z));
Quaternion deltaRotation = Quaternion.Euler(rotationAmount * Time.fixedDeltaTime);
this.transform.rotation = (this.transform.rotation * deltaRotation);

but I would like to align him to face the ground as well, something like:

Physics.Raycast(backLeft.position + Vector3.up, Vector3.down, out lr);
Physics.Raycast(backRight.position + Vector3.up, Vector3.down, out rr);
Physics.Raycast(frontLeft.position + Vector3.up, Vector3.down, out lf);
Physics.Raycast(frontRight.position + Vector3.up, Vector3.down, out rf);
upDir = (Vector3.Cross(rr.point - Vector3.up, lr.point - Vector3.up) +
Vector3.Cross(lr.point - Vector3.up, lf.point - Vector3.up) +
Vector3.Cross(lf.point - Vector3.up, rf.point - Vector3.up) +
Vector3.Cross(rf.point - Vector3.up, rr.point - Vector3.up)
).normalized;
Debug.DrawRay(rr.point, Vector3.up);
Debug.DrawRay(lr.point, Vector3.up);
Debug.DrawRay(lf.point, Vector3.up);
Debug.DrawRay(rf.point, Vector3.up);
this.transform.up = upDir;

Any ideas on how I could go about being able to rotate my player but also aligning him with the ground.

Thanks

Easiest way would be to use 2 transforms, one for the local, and one for the ground alignment.

Could you please give an example. I would be forever in your debt.

Well right now you have
Player (which has a transform)