Search Unity

Bug Cinemachine stutters switches between cameras when i move the mouse

Discussion in 'Cinemachine' started by marcusdyrholm, Jan 17, 2022.

  1. marcusdyrholm

    marcusdyrholm

    Joined:
    Mar 18, 2021
    Posts:
    11
    I have this on rails third person game I am creating, the camera I have following the character is a normal virtual camera where the body is set to transposer and simple follow of a follow target game object on the player character. When the character gets to one of the challenges in the game, a collider activates the game object of another virtual camera that has a higher priority so the player has a different viewpoint of the challenge.

    I have a camera blend from the player camera to any other active camera to ease in and out.

    What happens is when I move the mouse around in the game view the challenge viewpoint activates and deactivates rapidly. When the player character is moving and I move the mouse across the screen the camera also stutters a lot, falling behind the player and quickly snapping back to the correct position several times per second.

    Is there anyone who has experienced this issue before? Any help would be greatly appreciated.
     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    We'll need more information to figure this out.
    Do you experience any of the strange behaviour when you don't move the mouse? If no, what special things does your mouse do (e.g. moves an object)?

    Could you send a couple of screen shots of your Hierarchy, vcams (body and aim), components of the follow target?
     
  3. marcusdyrholm

    marcusdyrholm

    Joined:
    Mar 18, 2021
    Posts:
    11
    What happens is when the character arrives at a challenge a script lowers the priority of the virtual camera that is just following the player character and sets the challenge camera to be a higher priority. The only thing the mouse is used for is to click on an object in the scene which activates a canvas, other than that the mouse isn't used for anything.

    When I move the mouse the priority of the challenge camera goes to 0 while the player camera is unaffected. One of the weirder things is that the blending issue only happens every third or fourth time I run the game. While the stuttering issue is constant. I have scanned through my entire solution to see if there was any script that called the mouse position or something like it but there was nothing out of the ordinary.

    Here is the player camera:
    https://imgur.com/a/Wv1UI8B
    Here is the challenge camera:
    https://imgur.com/a/6ocNWpU

    Here is a video of the bug:
     
  4. marcusdyrholm

    marcusdyrholm

    Joined:
    Mar 18, 2021
    Posts:
    11
    I have managed to fix the switching issue, the priority changing was facilitated by entering a trigger collider. Changing the script to see if the trigger had been entered and then disabling the OnTriggerEnter after the first call fixed this.

    The stuttering issue remains however.
     
  5. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    In your video, the left cm camera is moving around. Is that the challenge camera?
     
  6. marcusdyrholm

    marcusdyrholm

    Joined:
    Mar 18, 2021
    Posts:
    11
    The virtual camera on the left is the player camera the one on the right is the challenge camera.

    But the issue pertaining to the camera switching back and forth between the challenge camera and the player camera when moving the mouse has been fixed.

    However, when I move the mouse while the game is running the framerate drops sharply and the camera stutters, lagging slightly behind the character and snapping back into position when I stop moving the mouse.
     
    Last edited: Feb 3, 2022
  7. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Could you submit a bug report with your project or a simplified version where we can reproduce the bug? It is difficult to tell what is causing the issue.