Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

unity camera follow with lerp

public Transform target;

public float speed = 2.0f;

void Update () {
    float interpolation = speed * Time.deltaTime;

    Vector3 position = transform.position;
    position.y = Mathf.Lerp(transform.position.y, target.position.y, interpolation);
    position.x = Mathf.Lerp(transform.position.x, target.position.x, interpolation);

    transform.position = position;
}
 
PREVIOUS NEXT
Tagged: #unity #camera #follow #lerp
ADD COMMENT
Topic
Name
5+3 =