Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Lag between player rotation and Cinemachine FreeLook target recentering

Discussion in 'Cinemachine' started by major_mandella, May 14, 2019.

  1. major_mandella

    major_mandella

    Joined:
    Feb 10, 2018
    Posts:
    4
    I'm trying to make a third person shooter like Risk of Rain 2. I'm using a Freelook camera using the Lock to Target No Roll binding mode and using the Composer Aim mode.

    I want the various pullback stages in the Y axis of the orbital camera, but I want the player's back to always be facing the camera since it's a shooter. Giving the Freelook camera control of the X axis made the aiming accurate, but prevented the player from strafing. When the player moved left and right, the player would start orbiting around the camera. I want the player to be able to strafe without rotating, and for the player to rotate with horizontal mouse movement.

    I removed the virtual camera's control of the x axis by deleting "Mouse X" from the horizontal axis field and enabled "Recenter to Target Heading" and set Wait Time and Recentering Time to 0. I've also set all damping options to 0.

    I then used the Mouse X to rotate the player in a script. The virtual Freelook camera does follow it, but it lags behind the rotation. After I stop moving the mouse, which is when the player stops moving, the camera continues to catch up with the player's rotation. Video of issue is below:



    In my script, I've tried updating the player's rotation in LateUpdate, FixedUpdate, and Update, but all return similar results.

    Code (CSharp):
    1. void LateUpdate() {
    2.         //rotation
    3.         mouseInput = Input.GetAxis("Mouse X");
    4.  
    5.         transform.Rotate(new Vector3(0, mouseInput * mouseXSpeed, 0), Space.Self);
    6.         print(mouseInput);
    7.  
    8.     }
    Here are screenshots of my virtual camera settings: https://imgur.com/cSKWpI9

    This isn't ideal for a shooter, since the camera continues to move after the mouse stops moving.

    I'm not sure if I'm doing something wrong like not using the right Update function, or if strafing without rotation with the Freelook camera isn't possible.

    Any help is appreciated!
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Are you sure you set all the damping to zero? It looks to me as though the orbital transposer still has some angular damping. Can you show me that part of the inspector?

    In terms of setup, I think you have the right idea. Lock the vcam to be behind the character's back, and use the mouse to control the character, not the vcam. Setting the FreeLook's XAxis input to nothing, and leaving xAxis.Value at 0 should be enough. Recentering will never happen, so long as the xAxis.Value stays at 0.
     
  3. major_mandella

    major_mandella

    Joined:
    Feb 10, 2018
    Posts:
    4
    Here's the images of the Top / Middle / Bottom Rig settings: https://imgur.com/a/jbPTnl4

    I've tried setting Angular Damping to Quaternion as well, and that resulted in the same issue.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    This is really weird. Can you export it as a package and send it to me?
     
  5. major_mandella

    major_mandella

    Joined:
    Feb 10, 2018
    Posts:
    4
    I've messaged you a link to the package. Thanks for looking into the problem.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Thanks. I had a look at it. The solution is to turn off X axis recentering :D
     
  7. major_mandella

    major_mandella

    Joined:
    Feb 10, 2018
    Posts:
    4
    Thank you so much! I knew it was probably something simple like that.