Search Unity

  1. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  2. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  3. If you couldn't join the live stream, take a peek at what you missed.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  5. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  6. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  7. 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:
    133
    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,217
    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:
    133
    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.