Search Unity

Question Having issues when using Cinemachine free look + damping + obstacle avoidance

Discussion in 'Cinemachine' started by Siegvar, Jul 28, 2020.

  1. Siegvar

    Siegvar

    Joined:
    Dec 30, 2014
    Posts:
    7
    Hi,

    I've been playing around with Cinemachine recently, and encountered some behaviour I couldn't unwrangle. Would appreciate some pointers.

    Context:
    I'm trying to set up a 3rd person orbit camera using Cinemachine's Free Look camera base, with damping on the character tracking, obstacle avoidance, and allowing players to control that camera with the right analog stick on a controller

    Individually each of those things work superbly, but things start to go awry when the damping, obstacle avoidance, and player controlled camera rotation need to work together. I've attached a video of the behaviour I'm getting for better illustration.

    At a distance, damping and camera rotation work as expected.
    • When the character moves the damping allows the character to drift slightly off the centre of the camera frame before the camera starts catching up.
    • When the camera is rotated via analog stick the character is kept dead centre in frame
    Once I'm at a close enough distance where the obstacle avoidance kicks in, the behaviour starts to get weird
    • When the character moves, behaviour still works as usual
    • When the camera is rotated, the character does not get kept dead centre in frame, and in fact the camera seems to over-rotate, to the point where the character hits against the hard boundaries of the camera altogether, before slowly easing back to centre of frame after players stop trying to rotate the camera


    What I expected to happen or hope to achieve is that even when obstacle avoidance is in play, rotating the camera will still keep the character in the middle of the frame.

    EDIT: This is my collider set up. It's a simple "Pull forward" behaviour with no smoothing or damping, just to keep the problem manageable.
    upload_2020-7-28_22-32-18.png

    I've more or less isolated it to the Aim damping not playing nice with collision, since when I turn the following 2 values to 0 I get no issues with rotating the camera when close to a wall.
    upload_2020-7-28_22-33-32.png
     
    Last edited: Jul 28, 2020
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Can you show your FreeLook inspector?
     
  3. Siegvar

    Siegvar

    Joined:
    Dec 30, 2014
    Posts:
    7
    Hi I just updated my original post with the inspectors that I think might be relevant. Let me know if I need to share more.
     
  4. Siegvar

    Siegvar

    Joined:
    Dec 30, 2014
    Posts:
    7
    Hmm... would it help if I uploaded my cinemachine virtual camera prefab? there's a lot of settings to look over with just a screenshot.

    EDIT: added my TPS free camera prefab in a zip file. I tried using this in the Cinemachine "Free look collider" example scene and got more or less the same behaviour you see in the video above.
     

    Attached Files:

    Last edited: Jul 28, 2020
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Thanks for sending the prefab, it was helpful.

    In the prefab, you had nonzero damping in the collider. That will cause this problem for sure. Setting collider damping to zero fixed the issue for me. It's safe to have damping in the Composer.
     
  6. Siegvar

    Siegvar

    Joined:
    Dec 30, 2014
    Posts:
    7
    Hi, thanks for the reply and help.

    Non Zero damping in collider helps, although it makes the collision kinda twitchy and gives me a little motion sickness. I'll try playing with it a bit more and see what I can do or if I have other questions.