Search Unity

Camera rotate by itself bug when using cinemachinefreelook

Discussion in 'Cinemachine' started by chenricky007, Apr 22, 2022.

  1. chenricky007

    chenricky007

    Joined:
    Mar 16, 2022
    Posts:
    8
    I had a problem when using cinemachinefreelook to make my third person camera.
    My camera keep rotate slowly by itself around the player object (a sample cylinder here)

    I follow some guide on the internet to change the binding mode to World Space, but that didn't fix the problem.
    Can anyone help?
    (Unity 2021.2.15f1)

     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    This is likely a problem with your hierarchy. Is your FreeLook a child of the main camera? If so, unparent it. Main camera, FreeLook, and target should all be separate objects, not parented to each other, or you can get feedback loops.
     
  3. chenricky007

    chenricky007

    Joined:
    Mar 16, 2022
    Posts:
    8
    Thanks for the reply.
    My Main camera, target(playerobject), and the FreeLook(thirdplayercamera) are separate like the pictrue shows.
    So it seems not the cause of the problem.

     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    In that case, I can see no reason for the FreeLook to rotate. Your settings look good. Can you reproduce this in an empty project?
     
  5. chenricky007

    chenricky007

    Joined:
    Mar 16, 2022
    Posts:
    8
    A simple project with just a cylinder as player and a plane work fine.
    It might be some other setting or script in the project cause this bug......

    I am making a random maze generator and the player can walk in the maze with third player camera.
    There will be a maze composed of many Wall prefabs when the game running.
    Maybe too many object in the secene cause this problem?

     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    No. Can you show a video of the problem?
     
  7. chenricky007

    chenricky007

    Joined:
    Mar 16, 2022
    Posts:
    8
    Thanks, here is the video.

     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    It looks as though someone is writing a small value in FreeLook.m_XAxis.InputAxisValue. Where is that coming from?

    upload_2022-4-22_11-15-5.png

    What happens if you delete that value while it's running? Does it come back?
    What happens if you delete "Mouse X" from Input Axis Name?
     
  9. chenricky007

    chenricky007

    Joined:
    Mar 16, 2022
    Posts:
    8
    The cinemachineFreeLook was just added into the scene, no other object or script modify FreeLook.m_XAxis.InputAxisValue.

    Delete FreeLook.m_XAxis.InputAxisValue change nothing, and it come back to 0.006683554 immediately.

    If I delete Mouse X, the camera stop ratate itself. But it means I can not use mouse or joysticks to rotate the camera.
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Cinemachine is just calling
    Input.GetAxis("Mouse X")
    , unless you have overridden
    CinemchineCore.GetInputAxis
    . Can you put a breakpoint to see what's going on?
     
  11. chenricky007

    chenricky007

    Joined:
    Mar 16, 2022
    Posts:
    8
    I try to print FreeLook.m_XAxis.InputAxisValue, and found that this value became 0.006683554 right after the first Update().
    Setting this value to 0 in Update() didn't help, it will come back to 0.006683554 immediately.
     
  12. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    You need to find out where this value is coming from. CM is not putting it there by itself. Do you have an override for CinemchineCore.GetInputAxis?
     
  13. chenricky007

    chenricky007

    Joined:
    Mar 16, 2022
    Posts:
    8
    Thanks for the reply.
    I am pretty sure there is no override for CinemchineCore.GetInputAxis, this thing is new to me.
     
  14. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Try putting a breakpoint in AxisState.cs where it calls GetInputAxis (around line 224). See what it's doing. That's the only time FreeLook reads input. Maybe you have some third-party assets in your project that are doing something fishy.

    Are you sure that you have no vestigial test code that's pushing a value into FreeLook.m_XAxis.InputAxisValue?
     
  15. chenricky007

    chenricky007

    Joined:
    Mar 16, 2022
    Posts:
    8
    I finally figure out the solution.
    It was a stupid setting problem, I forgot to set dead for my joystick control, so it kept giving a very small value.
    I should write this down somewhere.

    Thaks for your help.
     
    Gregoryl likes this.