Jitter when using an AC Game Camera to follow a UCC character

Cheo

Active member
Hello, I'm currently working on a Resident Evil-like game that does not use a UCC camera for rendering but rather AC Game Cameras that may have side scrolling enabled. While this feature works correctly when using AC's Tin Pot character, a ucc character tends to jitter when followed by an AC camera. The character is not actually jittering however, as evidenced by the scene view or even a switch to UCC's camera. Is there a conflict between how the UCC character and the AC camera move ? Here is the link to a thread I made in the AC forum I made about this : https://adventurecreator.org/forum/...ate-and-perhaps-a-camera-following-fix#latest

And here is a video showing the issue, it happens with a higher framerate as well but is heavier when locked at 60 fps :


Thanks in advance.

Edit : Completely forgot that as mentioned in the AC thread I can't play the AC-UCC demo scene in a fresh project because of two Camera Controller related errors :

Code:
[Exception] ArgumentNullException: Value cannot be null.
Parameter name: key
System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry() at <5d4cbfbeb62e454f98e19b231866113e>:0

System.Collections.Generic.Dictionary`2[TKey,TValue].TryGetValue() at <5d4cbfbeb62e454f98e19b231866113e>:0

EventHandler.GetActionList() at :0

EventHandler.UnregisterEventT1,T2 at :0

Adventure.AttachCharacter() at /Opsive/UltimateCharacterController/Scripts/ThirdPersonController/Camera/ViewTypes/Adventure.cs:38

CameraController.InitializeCharacter() at /Opsive/UltimateCharacterController/Scripts/Camera/CameraController.cs:429

CameraController.Start() at /Opsive/UltimateCharacterController/Scripts/Camera/CameraController.cs:359

Code:
[Error] Error: There is no look source attached to the character Atlas_AC. Ensure the character has a look source attached. For player characters the look source is the Camera Controller, and AI agents use the Local Look Source.
Adventure.GetDeltaYawRotation() at /Opsive/UltimateCharacterController/Scripts/ThirdPersonController/Character/MovementTypes/Adventure.cs:77

UltimateCharacterLocomotionHandler.GetRotationInput() at /Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotionHandler.cs:67

SimulationManager/CharacterComponents.Move() at /Opsive/UltimateCharacterController/Scripts/Game/SimulationManager.cs:59

SimulationManager.MoveCharacters() at /Opsive/UltimateCharacterController/Scripts/Game/SimulationManager.cs:278

SimulationManager.FixedUpdate() at /Opsive/UltimateCharacterController/Scripts/Game/SimulationManager.cs:241
 
Last edited:
I don't think that you'll be able to directly use the Adventure Creator camera with the character controller due to how the character controller updates. The right approach would be to create a new view type that interfaces with the Adventure Creator camera.
 
Okay, I'll try to make a script for that ! About my edit, the errors may have been caused by the test package I had imported into this project as well. When creating a new clean test project the AC-UCC demo scene could be started directly with no error but the third person adventure camera can't be moved around.
 
Alright, so I went for the simplest solution : I commented out this bit of code at the end of StateHandler._Update and pasted it at the end of FixedUpdate :

C#:
            if (!cameraIsOff)
            {
                foreach (_Camera _camera in cameras)
                {
                    _camera._Update();
                }
            }

Since UCC's movement updating seems to involve physics I figured FixedUpdate would magically resolve the issue - and it did ! Although I doubt it's the best solution, it'll do the trick for now but if anybody has a better one please let me know !
 
Hello, allow me to bump this thread as I have found new issues and the Fixed Update fix no longer works. Here is a new video :


In summary :

-The only way to get clean, jitter-free movement is to deactivate root motion and leave " _camera._Update();" in Update.

-Root motion seems to create or aggravate jittering.

-Jittering is much more noticeable when limiting the framerate to 60.

-Late Update doesn't solve the issue either.

I also tried creating a new view type that returns the AC Main Camera's position and rotation, but as expected this solves nothing, as the AC camera has trouble following the UCC character to begin with. Justin mentioned using an interface but I honestly don't know how to go about this, I'd really appreciate any help here !

Lastly, this video was recorded on Unity 2022.3.7f1, and using the latest versions of UCC, AC and the AC-UCC integration packages.
 
I am not sure on the AC integration part but to clarify:

Justin mentioned using an interface but I honestly don't know how to go about this, I'd really appreciate any help here !
Not an interface, but a ViewType that interfaces with. I would need to study more on how AC works but the idea is similar to Cinemachine where the CameraController still positions the camera but just takes the target position/rotation from Cinemachine. This way you get the smoothing as you do with the other camera types.
 
As I said, I have tried making a new view type that simply returns the AC camera's position and rotation, like this :

C#:
using UnityEngine;
using Opsive.Shared.Camera;
using Opsive.UltimateCharacterController.Camera;
using Opsive.UltimateCharacterController.Camera.ViewTypes;
using AC;
public class ACViewTest : ViewType
{
    private float m_Pitch;
    private float m_Yaw;
    private Quaternion m_BaseCharacterRotation;

    public override bool FirstPersonPerspective { get { return false; } }
    public override float Pitch { get { return m_Pitch; } }
    public override float Yaw { get { return m_Yaw; } }
    public override Quaternion BaseCharacterRotation { get { return m_BaseCharacterRotation; } }
    public override float LookDirectionDistance { get { return 100; } }

    public MainCamera ACCam;

    public override void ChangeViewType(bool activate, float pitch, float yaw, Quaternion baseCharacterRotation)
    {
        if (activate)
        {
            m_Pitch = pitch;
            m_Yaw = yaw;
            m_BaseCharacterRotation = baseCharacterRotation;
        }
    }

    public override Quaternion Rotate(float horizontalMovement, float verticalMovement, bool immediateUpdate)
    {
        return ACCam.transform.rotation;
    }

    public override Vector3 Move(bool immediateUpdate)
    {
        return ACCam.transform.position;
    }

    public override Vector3 LookDirection(Vector3 lookPosition, bool characterLookDirection, int layerMask, bool useRecoil, bool includeMovementSpread)
    {
        return m_BaseCharacterRotation * Vector3.forward;
    }
}

But the issue is still there, and I guess that makes sense precisely because we are copying a camera that doesn't work correctly to begin with. Is this what you had in mind ? If you have any other idea I'm all ears, I can make do with root motion disabled at the moment, but I'd be really thankful if I could get a correct following camera with and without root motion !

Edit : forgot to mention I made a new thread about this on the AC forum, it might be a more appropriate place to ask since the issue seems to originate from AC : https://www.adventurecreator.org/fo...-caused-by-root-motion-and-ac-camera/p1?new=1
 
Hello, I'm coming back to this thread on Chris's advice. Here's a new video I made :


At 2:25 I show my custom view type with AC's main camera disabled and UCC's camera enabled. You can see that movement with root motion is okay, but jumping (without root motion) causes the jitter issue to appear again. Putting the StateHander's camera.Update call in Late Update or Fixed Update changed nothing to that. Chris thought that you may offer insight as to the difference here.
 
Maybe it's a difference between when root motion is enabled versus not?
 
Well it's not maybe, there is a difference caused by root motion for sure ! Here are two videos in which I experiment with Cinemachine’s Dolly Track and end up with the same issues as with AC’s Game Camera, even when using the Third Person Cinemachine view type (which evidently wasn’t thoroughly tested) :



I will try messing with the Camera Controller tomorrow, see if we can make some sort of adaptation for when the character is using/not using root motion. In the meantime, I can't stress enough how important this issue is, anyone working on a Resident Evil-like game like I am is getting screwed at the moment ! And we’ll need both the Cinemachine and AC integration demo scenes to contain some working following cameras.
 
Following Chris's advice I tried every combination of Cinemachine Brain's Update Method and Blend Update Method, while using TP Combat view and the display of a cinemachine cam and while using the Third Person Cinemachine view and display of UCC's camera. The character was jittering in all cases. The only option I didn't test so far was the Manual Update.

Quoting Chris from the AC forum : "Your testing does suggest that a reliance on UCC's own camera view system is necessary to get pair smooth camera movement with UCC's root motion. Again, if Justin can elaborate on what he means by "how the character controller updates" being a factor, it may help shed light on this."
 
I tested a simple View Type made by Chris that updates an AC camera when Move is called, and commented out the camera update from State Handler. Unfortunately, it doesn't remove the jitter, but it might be useful to know that in comparison when enabling the AC Main Camera's Camera component we get some heavier jitter that occurs with and without root motion.

 
Chris fixed the issue with this miraculous line of code ! It needs to replace the existing one at line 212 of Game Camera :

C#:
? Vector3.Lerp (Transform.position, desiredPosition, 1 - Mathf.Pow(1f - Mathf.Clamp01 (dampSpeed), Time.deltaTime))

Here is a last video, in which I also show that changing the rigidbody interpolation mode didn't work while setting the follow speed to 0 removed the jitter :

 
Top