What about this function can't be executed in FixedUpdate?

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;
}

It shouldn’t be in FixedUpdate anyway; really only physics functions should be called there.

–Eric

Is there any way to make a camera follow the position and rotation of another object without it looking jerky?

Nope

Yes. Have you tried LateUpdate? You need to put the camera in the right position after the object has been put in the right position. Also, if your object is jerking around then the camera following it will do so too. You’d have to average out the camera’s position over a few frames to clear that up.

Also, if the object that it’s following is a rigidbody, then turn on interpolation or extrapolation. That way the object updates every frame instead of every physics frame (visually, anyway).

–Eric