I have a character the camera follows. All his movement code is in FixedUpdate, however there are times when he is on moving platforms that don’t use the physics engine, they are just animated, and I parent the character to the platform.
The problem is, if I put the SmoothDamp on FixedUpdate, it works great for normal physics steps, but then the non-physics movement (like when attached to moving platforms) jitters and looks like trash.
If I move the SmoothDamp to LateUpdate (or Update), the physics movement jitters and looks like trash, but the movement while on the moving platforms looks nice and smooth.
I am assuming this is because they are updated differently within the engine. The moving platforms movement is handled automagically every Update, while the physics movement is handled in discrete increments.
I thought that using LateUpdate would resolve these kinds of issues… but it doesn’t.
I also tried swapping around the script process order, as well as calling the camera movement from within the characters LateUpdate function, nothing seems to work at all.
On the other hand… If I don’t use a SmoothDamp or Slerp / Lerp, the camera looks perfect when I use it in LateUpdate.
Here is my code:
function LateUpdate(){
wantRotation = target.rotation;
wantRotation.eulerAngles.x = eulerX;
transform.rotation = wantRotation;
wantPosition = target.transform.TransformPoint(positionOffset);
transform.position.x = Mathf.SmoothDamp(transform.position.x, wantPosition.x, posDampVel.x, Time.deltaTime*7);
transform.position.z = Mathf.SmoothDamp(transform.position.z, wantPosition.z, posDampVel.z, Time.deltaTime*7);
transform.position.y = Mathf.SmoothDamp(transform.position.y, wantPosition.y, posDampVel.y, Time.deltaTime*10);
}
Any help is more than welcome! ![]()