Hello Everyone,
I’m making a simple controller to move my FPS player.
I’m able to rotate the player on the Y axis using the Mouse
float yRot = Input.GetAxisRaw("Mouse X");
Vector3 _rotation = new Vector3 (0f,yRot,0f) * lookSensitivy;
unitBody.MoveRotation (unitBody.rotation * Quaternion.Euler(_rotation));
And I’m able to Rotate with the normal of Ground
RaycastHit hit;
if (Physics.Raycast (transform.position, Vector3.down, out hit, 10)) {
transform.rotation = Quaternion.FromToRotation (transform.up, hit.normal) *transform.rotation;
}
But how can I merge both to use hit.normal for my X, The mouse input for the Y and Set the Z to Zero
Thank you.
if this can be done overtime would be awesome.