[BUG] Camera stutteres since update to UCC 2.3.3

echtnice

Member
Hi,

When using UCC with Update Location "FixedUpdate", the camera stutters with frame rates above 60?
If I revert the changes introduced in 2.3.3 of KinematicCamera, the stuttering disappears.

With Application.targetFrameRate set to 144, KinematicCamera.Move() gets called every second or third frame and therefore m_CameraController.Move() is called two or three time per KinematicCamera.Move() call.

With Update Location "FixedUpdate" I would have expected OnAnimatorMove (and therefore KinematicCamera.Move()) to be called every FixedUpdate (or once per frame in FixedUpdate) and the frame difference between calls never above 1.

The behavior can be reproduced in the demo scene even though i had to hide the default level and only test on a simple plane to get more than 60 frame. The stuttering is more observable with TopDown and Pseudo3D but was also observable with ThirdPerson Adventure (i think).

Any ideas on how to fix the camera stuttering?

Thanks!
 

Justin

Administrator
Staff member
In version 2.3.3 the camera is no longer framerate dependent with a fixed update loop. The change was in Kinematic Object Manager and if you compare the diff of that file you'll see what has changed.

I however am not able to reproduce any stutter in a fixed update. I sent this fix to a few people who were asking about it before release and they said that it is working well so I wonder why you are seeing stutter. Can you send a repro project to support@opsive.com so I can take a closer look?
 

Justin

Administrator
Staff member
Thanks for the scene. I was able to reproduce it and have a fix. Can you verify this works on your end?

Within KinematicObjectManager change both lines 406 and 416 to:

Code:
for (int i = m_LastUpdatedFrame; i <= Time.frameCount; ++i) {
 

echtnice

Member
No, unfortunately it didn't help.

According to the output of frames and index, you can see that the index is repeated.

return immediateUpdate ? targetPosition : Vector3.SmoothDamp(m_Transform.position, targetPosition, ref m_SmoothPositionVelocity, m_MoveSmoothing);
with ViewType of m_MoveSmoothing = 0 helps a little.

It works best without the new changes.

Update: Scene: TopDown ViewType and FieldOfView = 25

FixedUpdate: Scene: TopDown ViewType and FieldOfView = 25


Code:
Debug.Log($"!!!! {Time.frameCount} {Time.frameCount - m_LastUpdatedFrame}");

for (int i = m_LastUpdatedFrame; i <= Time.frameCount; ++i) {
 Debug.Log($"!!!! MoveIndex: {i}");
 m_CameraController.Move(m_LookVector.x, m_LookVector.y);
 }
m_LastUpdatedFrame = Time.frameCount;

AssignFixedLocation();
 

Justin

Administrator
Staff member
Hmm, ok, I will need to do some more testing. I'll get back to you. Here are a couple threads that this fix should have addressed:

 

nathanj

Active member
So glad I found this thread, this was driving me crazy trying to figure out what was going on. And sorry Justin, but I feel like my post is just gonna add to the complexity of this issue.

I was experiencing the jittery behaviour (looked identicaly to the videos echtnice posted above) if my scene ran under 60fps. As soon as I was able to get it to run over 60 fps it would run smooth. And, the fix that Justin posted above
Code:
for (int i = m_LastUpdatedFrame; i <= Time.frameCount; ++i) {
appears to have resoved the main part of my issue. I still get the odd camera jitter with the camera, its particaularily noticable when orbiting the player character.

Please feel free to ask for more details or anything that might be of help.

Thanks @echtnice for posting this thread, I couldn't figure out what was going on. I'd done some work to my Locomotion component and was sure I had dislodged something in there or that one of my Photon Views were not being set correctly.

I am using:
Unity 2020.3.12
UCC 2.33
Pun Addon 1.1.12
Photon PUN 2.32
 
Last edited:

Justin

Administrator
Staff member
This one has been tricky to debug but I actually think that the solution posted by @zroc will fix it for everyone. You should revert the changes from this thread and use the base 2.3.3 version. You'll then want to remove the fixed update assignment within the Animator Monitor:

Code:
m_Animator.updateMode = AnimatorUpdateMode.Normal;

Assuming this works for everyone I'll have a cleaned up version of this in the next update.
 

DavidC

Active member
This one has been tricky to debug but I actually think that the solution posted by @zroc will fix it for everyone. You should revert the changes from this thread and use the base 2.3.3 version. You'll then want to remove the fixed update assignment within the Animator Monitor:

Code:
m_Animator.updateMode = AnimatorUpdateMode.Normal;

Assuming this works for everyone I'll have a cleaned up version of this in the next update.
Can you be more specific? Like is this 988 in AnimatorMonitor.cs? Are we supposed to remove it, or replace it with the code you posted?
 

Justin

Administrator
Staff member
Yes to line 988 and you do want to replace it. The end result will be that the animator has an Update mode of Normal.
 
Top