Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  4. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

FreeLook Camera with follow lag

Discussion in 'Cinemachine' started by Kev00, Jun 5, 2018.

  1. Kev00

    Kev00

    Joined:
    Dec 6, 2016
    Posts:
    137
    I have a free look camera that follows a top down character.

    I'd like to add damping to the follow translation, but without altering the camera angle. I'm not really sure how to configure the FreeLookCamera or if it's even possible.

    For example, let's say the character is moving to position A. I want the vcam to smoothly translate to position A and lag behind the character's movement. Have it start slowly, increase speed, and then slow down as it locks on to position A. I've tried all kinds of settings but I just can't figure it out.

    I've managed to replicate what I'm looking for by having the Vcam follow a separate game object (PivotPoint) using the LockToTarget setting


    the code is something like this. MoveTo is the position of the character.

    Code (CSharp):
    1.      
    2. Vector3 relativePos = PivotPoint.position - VCam.transform.position;
    3. MoveTo.eulerAngles = new Vector3(0, Quaternion.LookRotation(relativePos).eulerAngles.y, 0);
    4. ...
    5.  
    6. MoveTo.Translate(newPosition, Space.Self);
    7. ...
    8.  
    9. PivotPoint.position = Vector3.Lerp(startPos, MoveTo.position, Time.deltaTime * panSpeed);
    10.  
    This does what I'm looking for, but I was wondering if there is a way to configure the FreeLookCamera to mimic the same behavior. It almost does it, but I'm not interested in the rotations it's adding.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,535
    Because the FreeLook handles positional damping and rotational damping independently, you'd have to tune all the dampings to exactly balance each other, or you'll get the rotations you don't want. Probably your method is the simplest: just get the FreeLook to follow a damped target.
     
  3. Kev00

    Kev00

    Joined:
    Dec 6, 2016
    Posts:
    137
    ok thanks. of course, I have no idea how to balance them all :) .. another method I'm considering is switching between to identical vcams. it probably the best method anyway, since I can selected the blend type.