Currently Im working on a space-shooter-demolevel. The ship rotates through mouse axis and i have a camera following it (smoothed with Lerp). My problem: The game is played at very high speed. My ships animation looks unsteady - strangely everything runs smooth when i have low framerates. I tried several things. What worked best so far is putting both (movement of camera and ship) into FixedUpdate. The animation looks smooth now. The environment however gets stuttering (a little) when framerates change. ..and i get the following error: !CompareApproximately (SqrMagnitude (m_LocalRotation), 1.0F) probably caused by Quaternion.Slerp. Quaternion.Lerp works without error. p.
I presume you are using rigidbodies? You should do your camera updating in LateUpdate and your player updating with physics in FixedUpdate. Then you should turn on rigidbody interpolation for the players rigidbody. This way your rigidbody will be interpolated between the physics frames and the camera will follow the interpolated position in a smooth way. http://unity3d.com/Documentation/ScriptReference/Rigidbody-interpolation.html
Yes rigidbodies with interpolation turned on. When the camera is in LateUpdate the animation looks very jittery.(framefate dependent - it gets worse when i fire weapon) I also get the !CompareApproximately error again. (is this something i can fix?)
It's undefined and you shouldnt rely on one or the other coming first. Instead you probably want to move one of them into the Update function, or alternatively call one function from the other to make the execution order explicit.
I ran into somethng familiar, perhaps you are seeing the same thing. What could be happening is that you are basing your camera's up direction on your ship's transform. So when the camera is lazily making its way to where it should be, the camera's up position is getting confused. If you watch it step by step, you will see the camera transform SNAP 180 degrees on it's forward axis. This is of course if this is the problem. Hopefully I gave you some insight.
I think its really because the cameras LateUpdate is called after other LateUpdate functions. Now i use two cameras, one for the player(fixedupdate) and one for the background(lateupdate). It works, i hope it doesnt take away too much performance.
Using two cameras -if you turn off clearing- doesn't have much overhead. If it works, fine, but i would still try to make sure the execution order is right. By either moving player movement code to Update instead of LateUpdate or calling the Update functions which depend on each other yourself, so you can fully determine the execution order.