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

public class MoveWithPlayer : MonoBehaviour
{
    [SerializeField] private float smoothing = 0.05f;

    private Vector3 m_Velocity = Vector3.zero;
    private Vector3 initialPosition;
    private Vector3 targetPosition;
    private Vector3 distance;

    void Awake()
    {
        initialPosition = gameObject.transform.position;
        distance = initialPosition - GameObject.FindWithTag("Player").transform.position;
        targetPosition = initialPosition;
    }

    void FixedUpdate()
    {
        targetPosition = GameObject.FindWithTag("Player").transform.position + distance;
        transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref m_Velocity, smoothing);
    }
}
