Search Unity

Question VirtualCamera drifting when not moving the mouse

Discussion in 'Cinemachine' started by rhysss, Nov 24, 2021.

  1. rhysss

    rhysss

    Joined:
    Jan 26, 2018
    Posts:
    8
    Hi,

    I've never used Cinemachine before but I have a class assignment where the base project includes a CinemachineVirtualCamera. In the editor, the camera drifts a little back and forth but it's not significant and would be barely noticable in a build. I put it down to an issue with my mouse, but in the build of my project the camera will slowly and continuously spin without any input from my mouse at all, and when trying to actually play the game, the camera drift makes aiming impossible.

    This is the VirtualCamera attached to an empty GameObject
    upload_2021-11-24_12-29-43.png
    upload_2021-11-24_12-30-0.png
    And this is the CinemachineBrain component attached to the camera. PlayerFollowCamera is the object with the VirtualCamera attached.
    upload_2021-11-24_12-31-8.png

    EDIT: I'm on Unity version 2020.3.20f1 and building for WebGL
     
    Last edited: Nov 24, 2021
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,726
    There should be no drift. Can you show the portion of your scene hierarchy that includes the vcam, the main camera, and the player?
     
  3. rhysss

    rhysss

    Joined:
    Jan 26, 2018
    Posts:
    8
    yup:
    upload_2021-11-24_12-49-39.png
    I believe these are from the first person starter assets package, and I'm building for WebGL, if that makes any difference. The only difference from the prefabs in that package is that I've changed the player move speed on the PlayerCapsule which has an otherwise unchanged FirstPersonController script.

    Also, realised I didn't say which version of Unity. I'm on 2020.3.20f1 (what we're told to use for the course so ideally a fix that doesn't involve updating Unity lol)

    I can get a video of the drift in the build in a moment.
     
  4. rhysss

    rhysss

    Joined:
    Jan 26, 2018
    Posts:
    8


    Around 18s is when I fully let go of the mouse, before then just shows how the camera drift happens even when I'm moving the mouse.
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,726
    If you just download the starter assets first-person package and run the sample scene unchanged, is there drift?
    Then, if you make your change to FirstPersonController and run it again, is there drift?
     
  6. rhysss

    rhysss

    Joined:
    Jan 26, 2018
    Posts:
    8
    Sorry, took a while to get a build for that scene, but there's drift there too.

    EDIT: Checked on Chrome as well and there's no drift there, but there is on Firefox?
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,726
    Is the drift only apparent in a build? Not in the editor?
     
  8. rhysss

    rhysss

    Joined:
    Jan 26, 2018
    Posts:
    8
    Yes, I haven't seen this happen at all in the editor, just in the builds and then seemingly not consistently between browsers.
     
    Gregoryl likes this.
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,726
    It's possibly a bug. I'll let the starter assets team take over and investigate this. Thanks for bringing it to our attention.
     
    rhysss likes this.
  10. bronsonzgeb

    bronsonzgeb

    Unity Technologies

    Joined:
    Aug 10, 2020
    Posts:
    101
    Hi @rhysss!

    I'm can't seem to reproduce the issue on my local machine. Can you tell me which version of Input System you have installed?

    Additionally, could you add this code to StarterAssetsInputs.cs? I'd like to see what value is displayed in your webGL build.
    Code (CSharp):
    1.         void OnGUI()
    2.         {
    3.             GUILayout.Label($"Look Input: {look}");
    4.         }
    Thanks!
     
  11. rhysss

    rhysss

    Joined:
    Jan 26, 2018
    Posts:
    8
    Hi! Sorry I didn't get back to you sooner!
    I have version 1.0.2 installed and the LookInput value seems to flicker between 0 and 15 in the x value.
     
  12. bronsonzgeb

    bronsonzgeb

    Unity Technologies

    Joined:
    Aug 10, 2020
    Posts:
    101
    I still can't reproduce it, but I was able to experience it in someone else's build, which is very unusual. The flickering value implies that the Input System is feeding a non-zero value. The fact that it's 15 seems to coincide with the Scale factor.

    upload_2021-11-29_14-15-33.png

    I'm investigating further with the InputSystem folks. I don't have an answer yet, but I wanted to give you an update.
     
    Gregoryl and rhyswinz like this.