Target Frame Rate of 60 or less breaks first person camera

Cheo

Active member
Hello, @RainerWahnsinn recently found a terrible bug that explains the camera issue he mentions there :

https://www.opsive.com/forum/index.php?threads/several-issues-with-ucc-and-urp-unity-2021-2022.9924/

Basically when using Application.targetFrameRate to set the target framerate to a value of about 60, the first person camera starts getting buggy and jerky, even more so when lowering the value to something like 30, at which point the camera may be sent flying around. This can be observable in UCC's demo scene alone. It is also worth clarifying that this is specifically about the target framerate - when setting my refresh rate to 60hz instead of 300hz I have no camera issues as long as the target framerate is not locked to 60 or less, as the fps count displayed by Unity's stats is still very high.

I suspect that this issue stems from one of UCC's latest versions, if not the latest - I would have seen it before on one of the previous versions when checking the framerate issues ! This needs an urgent look at, despite high fps count being nearly always better, games must allow for the option of capping the fps to 60 or 30 if the player chooses so (one of the possible reasons for that being to avoid overheating). I can take a look at a test package for this if necessary.
 
@RainerWahnsinn brought this up before and I replied to that thread with a video of me trying it out at 5 fps: https://streamable.com/27nvj4

This was in Unity 2021. I then tried 2022 and noticed the same problem as you. After looking into it more it's a problem with retrieving the transform position of the head. If you add the following script and assign the transform to the character's head bone you'll notice that the positions are wrong. This is why the camera is flying - Unity is reporting the incorrect head position. As a workaround for now you can set Smoothed Head Offset Steps to 0 on the first person camera. I will try to work around the issue but it may require a Unity bug report.
 

Attachments

  • PositionOutput.cs
    379 bytes · Views: 2
It looks like in Unity 2022 the Animator component went through some updates. As a result setting the updateMode to AnimatorUpdateMode.Update introduces the floating away issue. If you set the Animator Update Mode to Fixed then this issue goes away. I am not sure how it looks on framerates above 60 FPS though. @Cheo, can you test it? Set the update mode to Fixed in the inspector and then remove this line from AnimatorMonitor.InitializeItemParameters:

Code:
m_Animator.updateMode = AnimatorUpdateMode.Normal;
 
I confirm that setting Smoothed Head Offset Steps to 0 solves the camera issue, regardless of the fps or Animator Update Mode. However as I'm sure you already know this needs to be a temporary fix only, as it reduces camera movement.

If you set the Animator Update Mode to Fixed then this issue goes away.

There's no "Fixed" update mode for the Animator, the two other ones are Animate Physics and Unscaled Time, I'm assuming you're referring to Animate Physics ?
In any case if Smoothed Head Offset Steps isn't set to 0 then some camera jitter is experienced with a target frame rate of 60 with each update mode, but the camera flying around at 30 does not occur when using Animate Physics. However, using Animate Physics has some disastrous effects on the character model, which gets his body stretched out in different places when moving and starts jittering at 30.

Capture d’écran (1678).png

Hope all this is clear enough and helpful !

Edit : just to be clear, I tested on Unity 2022.3.4.
 
There's no "Fixed" update mode for the Animator, the two other ones are Animate Physics and Unscaled Time, I'm assuming you're referring to Animate Physics ?
No, in 2022 it separates Animate Physics and Update Mode:

1692197308807.png

I'm not sure which version of Unity 2022 adds that separation. I tried on Unity 2022.3
 
I see the Fixed option in Unity 2023.1.6, but I assure you I still see Animate Physics in 2022.3.4. In any case, it seems that Fixed has replaced Animate Physics.
 
I got my projects confused - you're right, it is split out in 2023. In any case when I change the animator to Fixed (2023.1) or AnimatePhysics (2022.x) this issue was fixed. I am thinking of adding an adaptive mode which will automatically change the animator update mode based on the framerate.
 
when I change the animator to Fixed (2023.1) or AnimatePhysics (2022.x) this issue was fixed.
Wait, I have to insist on that - do you not see the issues I pointed out, with the body stretched out when moving and the jitter when setting the target framerate to 30 ?

I am thinking of adding an adaptive mode which will automatically change the animator update mode based on the framerate.
I don't have your experience, but if you don't mind me saying so this sounds like a dubious and complicated workaround, if not a single update mode can handle both low and high framerates then there's some more fundamental issue that needs to be solved - easy for me to say of course, and if you do implement this fix I can take a look at it.
 
when I change the animator to Fixed (2023.1) or AnimatePhysics (2022.x) this issue was fixed.
Also can confirm this is not the case for me. I set all the Animators on Atlas from Normal to AnimatePhysics (2022.3.7f1) and still have the same issues. there is no Fixed value in there for me btw.

1692201430679.png
 
Did you also remove the AnimatorMonitor.InitializeItemParameters line? Without that line removed the Update Mode will reset back to update when the controller loads.

I made this change in a 2022.3 project and the camera is no longer flying away at 5fps. It does fly away if I don't make that change.
 
nope sorry I missed that. I commented out that line now... first person gets a bit better. camera not doing weird things anymore but the character itself is bumping/jittering. same in 3rd person view now but there it's even worse. I set all the Animators to "Animate Physics" (the Atlas model and also the first person components)

Update: switched from 30fps to 60fps:

1692205505741.png
 
It would take me a lot of work to get Atlas to do that if I tried :D

CharacterIK/camera isn't expecting the animator to be updated within FixedUpdate so that's the cause for third person. This really seems like a bug though on the Unity side of things since ideally the animator will still be updated within Update. I will continue to look into it with a minimal project. It may require me submitting a bug report to Unity but I'll let you know.
 
??

It would take me a lot of work to get Atlas to do that if I tried
I rly only did the usual steps of setting up UCC and atlas. it's a crazy screenshot, yes. but it's random how it looks like. the character fall apart into pieces is new now due to the latest changes I made in the Animator in combination with low fps. so basically changing to Update on Physics makes it worse and I just reproduced it in a new project.

btw I also noticed issues with the footsteps not playing synchronous, some times there are multiple at once with 1 step forward and some times they aren't there at all, pretty random. could be that this is related to the other issues, cause I can reproduce it too with low fps and it's fine with high fps. this is not specific to 1st person only btw, it happens in 3rd person view too.
 
Last edited:
Alright I did some more testing and can now report this:

somehow it all has to do with the Atlas prefab... I just searched the post of other ppl in the forums and saw you mentioning:

The Character field should be the Atlas fbx file rather than the Atlas prefab.
then I thought I give that a try,.. so I added the Atlas fbx model to the scene instead of the prefab and then I built the character (Only Atlas, no 2nd character) with both view types, then I added the firstperson arms and stuff

1692219563932.pngand only an assault rifle and bullets as items...

not a single issue at all so far
?

doesn't even matter what u set in the Animator, it rly just works. even on 30fps

well a little problem I have, but ig I just didn't do sth right yet. the assault rifle only fires 1 shot per click in 3rd person view, but is fine in 1st person. will do some more tests on that to find out. my weapon is not in correct place yet so maybe it has sth to do with that. but the movement issues are just gone!

10 fps? No Problem for UCC!

?curious to see if you guys can reproduce it. also if the problem arrives for me again when I continue to add things now, I will report back. hopefully, so maybe I find out what it is. I could also compare the new character with the prefab now
 
Last edited:
Thanks for tracking that down! Awesome. It looks like the Rigidbody interpolation mode on the child colliders is causing it. In pre-2022.x it could be set to interpolate but now it has to be set to none. You can fix this automatically by adding the following to line 131 of the Ragdoll ability:

Code:
                m_Rigidbodies[i].interpolation = enable ? RigidbodyInterpolation.Interpolate : RigidbodyInterpolation.None;
 
Just added this line of code and it does fix the issue, I can now play the demo scene at 30 fps without some camera jitter or the body getting stretched out when setting the update mode to Animate Physics/Fixed, good job !
 
OOOH THAT'S GREAT :love:
can confirm this solved that for me as well. probably also the footsteps issues, not sure I didn't test this out yet but it looks this issue is gone as well cause related
.. when setting the update mode to Animate Physics/Fixed, good job !
btw, for me I don't even need to change to Animate Physics, I didn't notice any difference yet between Normal And Animate Physics. did u experience issues when set to Normal?
 
Glad this fixed it! You should not need to change the animator update location.
 
Top