I have a problem with my camera. Since i linked it to the upper bosy rotating its just a little laggy, it doesnt fill so smooth as before. One extra question for some reason when i start unity the camera(upperBody) starts facing upwards probably beacuse of clamp but it shouldnt.Also I imported a soldier model from blender with bones, if that helps. I will be happy for any kind of help.
public class playerLook : MonoBehaviour
{
public float mouseSensitivity;
public Transform playerBody;
public Transform upperPlayerBody;
float xRotation;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, 30f, 120f);
upperPlayerBody.transform.localEulerAngles = new Vector3(xRotation, 0f, 0f);
playerBody.Rotate(Vector3.up * mouseX);
upperPlayerBody.Rotate(Vector3.right * mouseY);
}
}