If I call this function in Update it works but not in FixedUpdate and I can’t figure out why.
function CamRotation()
{
yRotationLookAt.transform.position = MainCam.transform.position;
yRotationLookAt.transform.LookAt(FocusTransform);
if(((Input.GetAxis("XRotation") == 0)(Input.GetAxis("Mouse X") == 0))(controlScript.sliddingOnWall == false)((Input.GetAxis("Vertical") != 0)||(Input.GetAxis("Horizontal") != 0)))
{
transform.eulerAngles.y = yRotationLookAt.transform.eulerAngles.y;
}
if((Input.GetAxis("YRotation") == 0)(Input.GetAxis("Mouse Y") == 0))
{
if(MainCam.transform.eulerAngles.x < 200)
{
if(MainCam.transform.eulerAngles.x < 80)
{
if((yRotationLookAt.transform.eulerAngles.x < 80)(yRotationLookAt.transform.eulerAngles.x > 20))
transform.eulerAngles.x = yRotationLookAt.transform.eulerAngles.x;
}
else if(MainCam.transform.eulerAngles.x > 80)
{
transform.eulerAngles.x = 79;
}
}
else if(MainCam.transform.eulerAngles.x > 200)
{
if(MainCam.transform.eulerAngles.x > 245)
{
transform.eulerAngles.x = yRotationLookAt.transform.eulerAngles.x;
}
else if(MainCam.transform.eulerAngles.x < 245)
{
MainCam.transform.eulerAngles.x = 246;
}
}
}
transform.eulerAngles.y += Input.GetAxis("XRotation") * Speed;
transform.eulerAngles.y += Input.GetAxis("Mouse X") * Speed;
if(MainCam.transform.eulerAngles.x < 200)
{
transform.eulerAngles.x += Input.GetAxis("YRotation") * Speed;
transform.eulerAngles.x += Input.GetAxis("Mouse Y") * -Speed;
}
else if(MainCam.transform.eulerAngles.x > 200)
{
transform.eulerAngles.x += Input.GetAxis("YRotation") * Speed;
transform.eulerAngles.x += Input.GetAxis("Mouse Y") * -Speed;
}
if(transform.eulerAngles.x == 270)
{
transform.eulerAngles.x = 275;
}
else if(transform.eulerAngles.x == 90)
{
transform.eulerAngles.x = 79.9;
}
yRotationLookAt.transform.position = MainCam.transform.position;
}