using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class camera : MonoBehaviour
{
    public Transform FollowedObject;
    public float Damping;
    private Rigidbody2D RB;
    private Vector2 RefVel;
    private Vector2 Target;
    private void Awake()
    {
        RB = this.gameObject.GetComponent<Rigidbody2D>();
    }
    void Update()
    {
        Target = new Vector2(FollowedObject.position.x, FollowedObject.position.y);
        RefVel = RB.velocity;
        RB.velocity = (Vector2.SmoothDamp(RB.position, Target, ref RefVel, 0.1f) - Target) * new Vector2(-1*Damping, -1*Damping);
    }
}